Exception handling 使用ServiceStack未处理的异常行为
我希望在不向响应DTO手动添加ResponseStatus的情况下获得自动异常序列化 基于未处理异常行为的信息,我编写了以下代码Exception handling 使用ServiceStack未处理的异常行为,exception-handling,
servicestack,Exception Handling,
servicestack,我希望在不向响应DTO手动添加ResponseStatus的情况下获得自动异常序列化 基于未处理异常行为的信息,我编写了以下代码 public class ContactService : RestServiceBase<Contact> { public override object OnGet(Contact request) { return ContactApi.GetContactInfo(request); } //To
public class ContactService : RestServiceBase<Contact>
{
public override object OnGet(Contact request)
{
return ContactApi.GetContactInfo(request);
}
//To trigger the serialization of the Exception to ResponseStatus
protected override object HandleException(Contact request, Exception ex)
{
throw ex;
}
<snip />
}
不完全清楚你到底想要什么。当出现错误时,您希望消费者最终看到什么?你能给我们展示一个你想要实现的输出的例子吗?更新了问题,包括我想要实现的输出。
{
"ResponseStatus":{
"ErrorCode":"ApplicationException",
"Message":"CRASH",
}
}