Class SimpleExceptionHandler
An exception handler that writes the message of the exception to the response and returns a 400 status code for expected exceptions or 500 for unexpected ones.
Implements
Namespace: Seltzr.ExceptionHandlers
Assembly: Seltzr.dll
Syntax
C#
public class SimpleExceptionHandler : IExceptionHandler
Constructors
Initializes a new instance of the SimpleExceptionHandler class.
C#
public SimpleExceptionHandler(bool isDevelopment)
Parameters
isDevelopment
Boolean
true if the app is in a development environment, false otherwise
Methods
Handles API exceptions
C#
public virtual Task<bool?> HandleException(Exception exception, HttpContext context, bool hasNext)
Parameters
exception
Exception
The exception that was thrown
context
HttpContext
The current request context
hasNext
Boolean
true if there is another middleware registered for this route, false otherwise
Returns
true if the request should continue and attempt to use the next middleware registered for this route, false to halt request execution,
C#
null
to continue with the next exception handler.