public ObjectResult HandleException(Exception exception) { var serviceException = (ServiceException)exception; return(_env.GetBadRequestResult(new BadRequestModel(serviceException.Message, serviceException, serviceException.Errors, serviceException.ErrorCode))); }
public override void OnException(ExceptionContext context) { var handler = _handlers.FirstOrDefault(f => f.ExceptionType == context.Exception.GetType()); context.Result = handler != null ? handler.HandleException(context.Exception) : _env.GetBadRequestResult(new BadRequestModel(DefaultErrorMessage, context.Exception)); context.ExceptionHandled = true; }