-
Notifications
You must be signed in to change notification settings - Fork 81
Remove silly formatException class from MessageHandler #9144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove silly formatException class from MessageHandler #9144
Conversation
// The ApplicationContext is practically always an Adapter except when the listener is created directly via the LarvaScenarioContext | ||
private Message formatExceptionUsingErrorMessageFormatter(PipeLineSession session, Message inputMessage, Throwable t) { | ||
if (applicationContext instanceof Adapter adapter) { | ||
return adapter.formatErrorMessage(null, t, inputMessage, session, null); | ||
} | ||
|
||
log.warn("unformatted exception while processing input request [{}]", inputMessage, t); | ||
return new Message(t.getMessage()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although over here we can safely assume the ApplicationContext
is always an Adapter
, I've copied this block from the JavaListener
.
@@ -177,7 +178,7 @@ private Message processRequest(@Nonnull MessageWrapper<M> messageWrapper, @Nonnu | |||
} catch (ListenerException e) { | |||
// Message with error contains a String so does not need to be preserved. | |||
// (Trying to preserve means dealing with extra IOException for which there is no reason here) | |||
return handler.formatException(null, session, message, e); | |||
return formatExceptionUsingErrorMessageFormatter(session, message, e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is quite strange, this listener should always just throw the exception, it's up to the callee
to format it using the correct ErrorMessageFormatter
if any.
*/ | ||
Message processRequest(IListener<M> origin, RawMessageWrapper<M> rawMessage, Message message, PipeLineSession session) throws ListenerException; | ||
Message processRequest(IPushingListener<M> origin, RawMessageWrapper<M> rawMessage, Message message, PipeLineSession session) throws ListenerException; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree this ain't perfect, but for now we are limiting the code-execution flow in implementing to call the correct 'entrypoint' for the receiver.
Initially looks good except a stupid test that fails! |
|
No description provided.