Is it possible to achieve a global policy which can throw different customized error responses based on the type of error thrown?
For eg : for http 500 -> Error message 1
http 404 -> Error message 2
SQL attacks -> Different error
Invalid API key -> Different error
I understand that types of possibles errors will be numerous and would be difficult to categorize each of them. But my idea is to have some custom error responses for certain set of known errors and I can have a generic error for all the other unhandled errors.
Has anyone done similar to this? Really appreciate your suggestions.
Please use the Customize Error Response Assertion. This assertion helps you to customize the error that you are sending back. You can choose a Http response status as well. Although this is not a global setting, it can be used where ever you need to send a customized error response.
Please mark the above answer as correct if it has helped you to answer your question.