GlobalErrorHandler breaks precessing response and not executing response-middlewares
See original GitHub issueI need to transform error response by middlewares, such as normat responses.
GlobalErrorHandler breaks precessing response and not executing ResponseExtractMiddleware, EncodeJsonMiddleware.
middlewares: [
GlobalErrorHandler,
ResponseExtractMiddleware,
EncodeJsonMiddleware,
],
const ResponseExtractMiddleware = () => ({
response(next) {
return next().then((response) => {
console.log('ResponseExtractMiddleware->response:63', response);
return {
status: response.status(),
data: response.data().data,
headers: response.headers(),
};
})
},
});
const CONTENT_TYPE_JSON = 'application/json;charset=utf-8';
const EncodeJsonMiddleware = () => ({
request(request) {
try {
if (request.body()) {
const content = JSON.stringify(request.body());
return request.enhance({
headers: {'Content-Type': CONTENT_TYPE_JSON},
body: content,
});
}
}
catch (e) {
return request;
}
}
});
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Mule 4 error handling deep dive - MuleSoft Blog
The answer is: utilize the On Error Continue scope in your global error handler. Payload is successfully set to “Success – Started Flow”;...
Read more >Mule 4 Error Handling Tutorial | On Error Propagate - YouTube
How to use Global Error Handler in Mule 4. * How to use Catch Scope in Mule 4. * How to transform Error...
Read more >The mappersmith from tulios - GithubHelp
GlobalErrorHandler breaks precessing response and not executing response-middlewares. I need to transform error response by middlewares, such as normat ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks for reporting, I’ll improve the docs based on this ticket. Thanks again!
It`s correct example. return in catch will convert exception to good responce.