private async Task handleCustomExceptions(BaseException ex, HttpContext httpContext) { if (ex.code == 0) { ex.code = HttpStatusCode.InternalServerError; } var response = new QueueExceptionDto(); response.Message = ex.Message; response.Status = ex.code.ToString(); response.RequestedUri = httpContext.Request.Path; response.Timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm tt"); response.Origin = ex.origin; httpContext.Response.ContentType = "application/json"; httpContext.Response.StatusCode = (int)ex.code; await httpContext.Response.WriteAsync(response.SerializeModel()); if (ex.code.Equals(HttpStatusCode.InternalServerError)) { _manager.Publish(response); } }
private async Task handleAll(Exception ex, HttpContext httpContext) { var response = new QueueExceptionDto(); response.Message = ex.Message; response.Status = HttpStatusCode.InternalServerError.ToString(); response.RequestedUri = httpContext.Request.Path; response.Timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm tt"); response.Origin = getOriginBasedOnContext(httpContext.Request.Path); httpContext.Response.ContentType = "application/json"; httpContext.Response.StatusCode = (int)HttpStatusCode.InternalServerError; await httpContext.Response.WriteAsync(response.SerializeModel()); _manager.Publish(response); }