public static IActionResult ApiError(this Controller controller, ModelStateDictionary modelState) { var errList = GetModelStateErrors(modelState); var response = new RtApiErrorResponse(errList); return(controller.Json(response, SerializationSettings));; }
public override Task OnExceptionAsync(ExceptionContext context) { context.HttpContext.Response.StatusCode = (int)HttpStatusCode.InternalServerError; var apiError = new RtApiErrorResponse(context.Exception); _log.LogError(context.Exception, "Internal server error"); context.Result = new JsonResult(apiError); return(base.OnExceptionAsync(context)); }
public static IActionResult ApiError(this Controller controller, Exception ex) { var response = new RtApiErrorResponse(ex); return(controller.Json(response, SerializationSettings)); }