Replies: 4 comments 2 replies
-
@bwn-z I don't think so this is even possible, because: Anything breaks with ocelot, everything comes with message and status codes defined @ggnaegi @raman-m can you please check my thoughts & close this if my answer sounds correct? |
Beta Was this translation helpful? Give feedback.
-
@bwn-z Your idea to catch all exceptions in Ocelot is wrong! Don't try that because it is impossible. Regarding having the exception object. It is impossible to catch this object now. But in theory, we can enhance Again, imagine you got exception object. And what are you going to do with this object? |
Beta Was this translation helpful? Give feedback.
-
@bwn-z |
Beta Was this translation helpful? Give feedback.
-
Yes, this will work for sure! 😄 🚀 Or, maybe, you could use the extension method It's just an idea, I haven't tried it. app.UseStatusCodePages(new StatusCodePagesOptions
{
HandleAsync = async ctx =>
{
if (ctx.HttpContext.Response.StatusCode == 404)
{
await ctx.HttpContext.Response.WriteAsync("Uuuups, path not found...");
}
}
}); |
Beta Was this translation helpful? Give feedback.
-
Expected Behavior / New Feature
I want to add my custom exceptionMiddleware and catch all exception in it.
I want to do this because I don't like the default error response (statusCodes: 400+, 500+) from ocelot without json body and info.
Obviously you can just add middleware as normal before the call to app.UseOcelot() It cannot be added after as Ocelot does not call the next middleware.
Actual Behavior / Motivation for New Feature
I added my custom exceptionMiddleware and It doesn't get the exceptions after DelegatingHandler callings.
Steps to Reproduce the Problem
app.UseMiddleware<ExceptionMiddleware>()
;app.UseOcelot().Wait();
public void ConfigureServices(IServiceCollection services)
:services.AddOcelot(Configuration).AddDelegatingHandler<SomeDelegatingHandler>();
"DelegatingHandlers" : [ "SomeDelegatingHandler" ]
for a some route.Specifications
Beta Was this translation helpful? Give feedback.
All reactions