Last active
October 17, 2024 19:09
-
-
Save DaRiv94/7966d72fa31fd7473957debf44f41244 to your computer and use it in GitHub Desktop.
Error Handling in Azure API Management
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <set-header name="ErrorSource" exists-action="override"> | |
| <value>@(context.LastError.Source)</value> | |
| </set-header> | |
| <set-header name="ErrorReason" exists-action="override"> | |
| <value>@(context.LastError.Reason)</value> | |
| </set-header> | |
| <set-header name="ErrorMessage" exists-action="override"> | |
| <value>@(context.LastError.Message)</value> | |
| </set-header> | |
| <set-header name="ErrorSection" exists-action="override"> | |
| <value>@(context.LastError.Section)</value> | |
| </set-header> | |
| <set-header name="ErrorStatusCode" exists-action="override"> | |
| <value>@(context.Response.StatusCode.ToString())</value> | |
| </set-header> | |
| <set-header name="ErrorScope" exists-action="override"> | |
| <value>@(context.LastError.Scope)</value> | |
| </set-header> | |
| <set-header name="ErrorPath" exists-action="override"> | |
| <value>@(context.LastError.Path)</value> | |
| </set-header> | |
| <set-header name="ErrorPolicyId" exists-action="override"> | |
| <value>@(context.LastError.PolicyId)</value> | |
| </set-header> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <choose> | |
| <when condition="@(context.Response.StatusCode == 500)"> | |
| <return-response response-variable-name="existing response variable"> | |
| <set-status code="500" reason="Internal Server Error" /> | |
| <set-header name="failure" exists-action="override"> | |
| <value>failure</value> | |
| </set-header> | |
| <set-body>Sorry, We had an error on our end</set-body> | |
| </return-response> | |
| </when> | |
| </choose> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment