Skip to main content

Exception

These CodeGen configurations allow you to control exceptions thrown in APIMatic generated SDKs.

Error Templates

This setting allows the configuration of error messages using custom templates that can be provided for overriding default exception messages thrown in SDKs for error responses.

Usage

To use this feature, you need to specify a Map<string, string> value, where keys would be error codes or ranges and values would be template error messages. By default, its value is set to null.

"info": {
...
"x-codegen-settings": {
"ErrorTemplates": {
"401": "Failed to authorize, Code: {$statusCode}.",
"5XX": "Internal server error, Code: {$statusCode}.",
"0": "An error occurred. Code: {$statusCode}"
}
}
}

Language Support

C#JavaPHPPythonRubyTSGo
✔️✔️✔️✔️✔️✔️✔️

Change in SDK

Configuring this setting will affect the error messages thrown on error codes for all SDKs. This behavior is documented in detail here