Skip to main content

Exception

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

Generate Exceptions

note

Please note that this setting has been deprecated. There are no plans to provide any future support or updates for it.

This setting allows generation of exception classes for Custom error types defined by the user. If you disable this setting, generic exceptions will still be thrown.

Usage

To use this feature, you need to specify a Boolean value. By default, its value is set to true.

"info": {
...,
"x-codegen-settings": {
"GenerateExceptions": true
}
}

Language Support

C#JavaPHPPythonRubyTSGo
✔️✔️

Change in SDK

Configuring this setting has the following effect on the generated SDK:

Value Change
true (default)
try:
result = controller.get_data()
print(result)
except RandomException as e:
print(e)
except DataException as e:
print(e)
except AuthorizationException as e:
print(e)
except APIException as e:
print(e)
false
try:
result = controller.get_data()
print(result)
except APIException as e:
print(e)