【发布时间】:2014-05-23 09:36:37
【问题描述】:
我刚刚看了这篇关于处理web api中的错误消息的文章, Article
但现在我想列出我所有预定义的错误,
到目前为止我已经尝试过:
public class ConnectionTimeoutError : HttpError
{
public ConnectionTimeoutError()
{
HttpError myCustomError = new HttpError("Timeout while trying connect to the device") { { "CustomErrorCode", 33 } };
}
}
然后我尝试像这样使用它:
HttpResponseMessage msg = Request.CreateErrorResponse(HttpStatusCode.BadRequest, new ConnectionTimeoutError());
return msg;
不是百分百
我该怎么办?
【问题讨论】:
标签: c# asp.net asp.net-web-api httpresponse http-error