【发布时间】:2015-12-07 21:14:27
【问题描述】:
使用 ServiceStack,在两个地方实现异常处理/日志记录很重要:
-
Inside of each
ServiceRunner<T>.public class MyServiceRunner<T> : ServiceRunner<T> { public override object HandleException(IRequestContext requestContext, T request, Exception ex) { // Implement your exception handling/logging here. // T request is your request DTO. } } -
Inside of AppHost,以便您可以处理服务之外发生的未处理异常。
public override void Configure(Container container) { ExceptionHandler = (req, res, operationName, ex) => { //Handle Unhandled Exceptions occurring outside of Services //E.g. Exceptions during Request binding or in filters: } }
我的问题:
- 在 #1 中,您可以轻松访问请求 DTO(即用于记录目的)。
- 在处理服务之外发生的异常时,我是否有权访问请求 DTO(或等效的请求负载)?
【问题讨论】:
标签: c# servicestack servicestack-bsd