Open xhafan opened 3 months ago
@mookid8000 I committed an attempt to fix this: https://github.com/xhafan/Rebus/commit/4be1c8e0a215a3f903566e31da30503e29517a88 Could you please have a look and let me know if you would approve this approach. If yes, I will add unit tests, and create a pull request. If no, please suggest improvements 🙂. Thank you.
Hi @xhafan , did you read the section about exception info on the wiki? 👉 https://github.com/rebus-org/Rebus/wiki/Automatic-retries-and-error-handling#exception-information
Yes, I have read it. But it does not work for me as DefaultRetryStep
news up ExceptionInfo
directly instead of using ExceptionInfo
factory, and as a result the error handler gets an instance of ExceptionInfo
and not InMemExceptionInfo
.
@mookid8000 Is my implementation of IErrorHandler
correct, or should I try to use IFailed<TMessage>
instead?
I can report the same issue.
It seems that inside of the method HandlePoisonMessage in a custom IErrorHandler, we cannot cast the ExceptionInfo exception parameter to the InMemExceptionInfo or any other custom ExceptionInfo.
Here's the exception when using the default InMemExceptionInfo:
Here's the InMemExceptionInfo configuration:
I've read the wiki and tried out a custom IExceptionInfoFactory, as well, but with the same result.
Any suggestion, workaround or a fix, please? We rely on a custom exceptions with specific properties, so accessing only the exception type or message from the base ExceptionInfo is not enough.
Thanks!
We have the same issue described in the previous comments. The original exception is being lost, and we cannot access it in the HandlePoisonMessage
of IErrorHandler
, as the exception info cannot be cast to InMemExceptionInfo
. Any fix so far?
We've run into the same issue with the original exception being lost by the time it reaches a custom IErrorHandler
. This seems to happen because of the GetAggregateException
method in DefaultRetryStep
, which creates a new ExceptionInfo
and simply concatenates the messages of the child ExceptionInfos, again losing the context of the original instance.
GetAggregateException
is unfortunately static non-virtual so can't be overridden without re-implementing the entire retry step.
My suggestion would be to update the DefaultRetryStep.GetAggregateException
method to return a custom ExceptionInfo
subclass which internally holds a reference to the child ExceptionInfos (from which the original exception could then be retrieved if required. Ideally if this method could be made protected virtual
rather than private static
this would be extremely useful for customising the process too.
I have this Rebus 7
IErrorHandler
implementation to report failed messages on Slack:It uses
Exception.InnerException
to detect the exception thrown in the message handler, and behave differently based on the exception type.In Rebus 8,
Exception
has been changed toExceptionInfo
without access toInnerException
. I refactored the code to this:Not ideal in my opinion that the
InnerException
disappeared, and it's now doing a stringology (exception.Details.Contains(nameof(UserException))
). Is there a better way in Rebus how to implement failed message reporting, and get access to the thrown inner exception message?Also reported on SO: https://stackoverflow.com/questions/77804512/rebus-7-ierrorhandler-implementation-not-compatible-with-rebus-8