Exception Handling

Design question here:
The wiki ErrorHandling does a real good job of explaining all the hooks for doing our own thing when exceptions are raised and control what is raised, and how to represent them on the wire.

Within our service, we are deliberately throwing various .NET exceptions that then map to HTTP status codes (4XX) using the MapExceptionToStatusCode map.
For example:

MapExceptionToStatusCode =
            {
                { typeof(ValidationError), 400 },
                { typeof(ArgumentException), 400 },
                { typeof(ArgumentNullException), 400 },
                { typeof(ArgumentOutOfRangeException), 400 },
                { typeof(RuleViolationException), 400 },
                { typeof(AuthenticationException), 401 },
                { typeof(UnauthorizedAccessException), 401 },
                { typeof(ForbiddenException), 403 },
                { typeof(ResourceNotFoundException), 404 },
                { typeof(RoleViolationException), 404 },
                { typeof(ResourceConflictException), 409 },
            }

Now, I want to do something very special if the service throws an exception not in this map, ones that would go to the client as a HTTP 500.

The wiki Register handlers for handling Service Exceptions recommends one of two handlers where I can process these exceptions and do what I want.

So my question is, how and where would I only process exceptions that would result in a 500? (and not any of the ones in my MapExceptionToStatusCode map.) I only want to log the 500’s not the 4XX’s

You can call the ex.ToStatusCode() in the handler to find out what the response status code is for the exception, sounds like you just want to check for ex.ToStatusCode() == 500.