Skip to content

How to catch Ocelot exceptions? #2009

Answered by raman-m
Tingtzong asked this question in Q&A
Discussion options

You must be logged in to vote

@Tingtzong

Actual Behavior / Motivation for New Feature

ocelot not throw this exception, swallowed, so the try-catch did not work.

Exactly! Have you ever heard or read about Error Status Codes feature?
We have a global Exception handler which prevents Ocelot instance failing/hanging because of 5xx errors in downstream services.
But we don't consider this design good because we override status and some headers. See notes about Design

Please develop Delegating Handler to catch exceptions in and read original status of downstream service response.
A delegating handler is exactly right place to catch exception, but we recommend to re-throw it!

Also, PreErrorResponderMiddleware injection sho…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by raman-m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #1210 on March 23, 2024 17:05.