【发布时间】:2017-04-21 01:50:32
【问题描述】:
我运行了 Exceptionless 项目,我们有一些客户在使用 ServiceStack,我有一些问题以及对您的错误处理的建议。目前你们不会将异常传递给 asp.net 核心中间件或任何diagnostics integrations,这是一个问题。有一个向这些钩子报告的包可能会很好。相反,您吃掉所有异常并调用两个处理程序之一:
ServiceExceptionHandlers.Add((httpReq, request, exception) => {
var contextData = new ContextData();
contextData.MarkAsUnhandledError();
contextData.SetSubmissionMethod("ServiceExceptionHandlers");
exception.ToExceptionless(contextData).Submit(); // TODO: figure out how to get the http context here for extra metadata.
return null; //continue with default Error Handling
});
//Handle Unhandled Exceptions occurring outside of Services
//E.g. Exceptions during Request binding or in filters:
UncaughtExceptionHandlers.Add((req, res, operationName, ex) => {
var contextData = new ContextData();
contextData.MarkAsUnhandledError();
contextData.SetSubmissionMethod("UncaughtExceptionHandlers");
ex.ToExceptionless(contextData).SetProperty("Operation", operationName).Submit(); // TODO: figure out how to get the http context here for extra metadata.
// TODO: See if we have to do this,, rather just fallback and let them handle it.
res.Write("Error: {0}: {1}".Fmt(ex.GetType().Name, ex.Message));
res.EndRequest(skipHeaders: true);
});
您可以看到我不想中断任何我只想登录并继续的工作流程...有没有什么好的方法来完成这个?
另外,我如何才能访问 http 上下文(您传递请求、响应和异常,但没有其他内容)。我知道它被抽象出来了,这里没有任何上下文,也许可能有一个属性包我可以查看以获得上下文?我想要这个,以便我可以捕获更多元数据(请求、用户等...)
【问题讨论】:
标签: servicestack