Created
February 19, 2019 18:06
-
-
Save 2garryn/a71984ee55d13e5e79ffa230ecbff73c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task InvokeAsync(HttpContext httpContext) | |
{ | |
httpContext.Response.ContentType = "application/json"; | |
httpContext.Response.StatusCode = 200; | |
try | |
{ | |
await _next(httpContext); | |
} | |
catch (InternalException.Error em) | |
{ | |
await httpContext.Response.WriteAsync(ExceptionToString(em)); | |
} | |
} | |
private string ExceptionToString(InternalException.Error exp) | |
{ | |
var reply = new | |
{ | |
isError = true, | |
code = exp.ErrorCode, | |
message = exp.ErrorMessage | |
}; | |
return JsonConvert.SerializeObject(reply); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment