static MartenExceptionTransformer()
        {
            _transforms.AddTransform <EventStreamUnexpectedMaxEventIdExceptionTransform>();
            _transforms.AddTransform <MartenCommandNotSupportedExceptionTransform>();

            _transforms.IfExceptionIs <PostgresException>()
            .If(e => e.SqlState == PostgresErrorCodes.SerializationFailure)
            .ThenTransformTo(e => throw new ConcurrentUpdateException(e));

            _transforms.IfExceptionIs <NpgsqlException>()
            .TransformTo(e =>
            {
                var command = e.ReadNpgsqlCommand();
                return(new MartenCommandException(command, e));
            });
        }
예제 #2
0
 public ExceptionTransformsTester()
 {
     theTransforms.AddTransform <CustomTransform>();
     theTransforms.IfExceptionIs <InvalidOperationException>()
     .If(e => e.Message.Contains("Bad"))
     .ThenTransformTo(e => new CustomException2("It was bad", e))
     .If(e => e.Message.Contains("Wrong"))
     .ThenTransformTo(e => new WrongException("It was wrong", e))
     .IfInnerIs <WrongException>().ThenTransformTo(e => new CustomException3("It was wrong", e))
     ;
 }