1

ServiceStack では、次の 2 つの場所で例外処理/ログを実装することが重要です。

  1. それぞれの内部 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.
              }
        }
    
  2. 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 (または同等のリクエスト ペイロード) にアクセスできますか?
4

1 に答える 1