/// <summary> /// Handles the specified exception by rethrowing it /// </summary> /// <param name="ex"></param> /// <param name="context"></param> public virtual HttpResponseMessage HandleException(ExceptionContext context, BaseApiException ex) { HttpResponseMessage result = null; result = result ?? HandleExceptionInternal(context, ex as ApiControllerNotFoundException); result = result ?? HandleExceptionInternal(context, ex as AmbigiousApiRequestException); result = result ?? HandleExceptionInternal(context, ex as ApiVersionFormatException); result = result ?? HandleExceptionInternal(context, ex as ApiVersionNotDeterminedException); return result; }
/// <summary> /// Handles the specified exception by rethrowing it /// </summary> /// <param name="ex"></param> /// <param name="context"></param> public virtual HttpResponseMessage HandleException(ExceptionContext context, BaseApiException ex) { HttpResponseMessage result = null; result = result ?? HandleExceptionInternal(context, ex as ApiControllerNotFoundException); result = result ?? HandleExceptionInternal(context, ex as AmbigiousApiRequestException); result = result ?? HandleExceptionInternal(context, ex as ApiVersionFormatException); result = result ?? HandleExceptionInternal(context, ex as ApiVersionNotDeterminedException); return(result); }
/// <summary> /// When overridden in a derived class, handles the exception synchronously. /// </summary> /// <param name="context">The exception handler context.</param> public override void Handle(ExceptionHandlerContext context) { HttpConfiguration httpConfig = context.ExceptionContext.RequestContext.Configuration; BaseApiException exceptionThrown = context.Exception as BaseApiException; if (exceptionThrown != null) { IVersioningExceptionHandler exceptionHandler = httpConfig.DependencyResolver.GetVersionExceptionFilter(); HttpResponseMessage result = exceptionHandler.HandleException(context.ExceptionContext, exceptionThrown); if (result != null) { context.Result = new ResponseMessageResult(result); } } }