Feature/exception response (#663)
* return 500 code for other exception with json response * not throw
This commit is contained in:
@@ -24,7 +24,7 @@ public class ExceptionMiddleware
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await HandleExceptionAsync(httpContext, ex);
|
await HandleExceptionAsync(httpContext, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,5 +41,12 @@ public class ExceptionMiddleware
|
|||||||
Message = duplicationException.Message
|
Message = duplicationException.Message
|
||||||
}.ToString());
|
}.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
|
||||||
|
await context.Response.WriteAsync(new ErrorDetails()
|
||||||
|
{
|
||||||
|
StatusCode = context.Response.StatusCode,
|
||||||
|
Message = exception.Message
|
||||||
|
}.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user