【发布时间】:2016-04-04 09:40:53
【问题描述】:
我想在 Web API 中实现自定义异常处理。
我能够实现一些初始实现,但是我想将类对象传递给异常以显示所有属性。喜欢
class error
{
int error_code
string error_message
string API
}
当出现一些错误时,它应该显示类似 json
{
"error_code": 0,
"error_message":"Either Your are not authorized or you don't have any project yet.",
"API": "save data"
}
此代码仅显示消息
throw new HttpResponseException(
Request.CreateErrorResponse(HttpStatusCode.NotFound, message));
任何建议,
谢谢
【问题讨论】:
标签: c# asp.net-web-api exception-handling