Hide menu
Loading...
Searching...
No Matches
Error handling

Overview

Originally, CAD Exchanger had a limited error handling approach: returning boolean values indicating whether the operation succeeded or failed. It's simple, but lacks flexibility in reporting exactly what went wrong.

Starting with version 3.5.3 CAD Exchanger introduces another error handling approach based on C++ exceptions. The new approach works on an opt-in basis to preserve source and binary compatibility. To enable the new mechanism enable the Base_Settings::UseExceptions feature-flag as follows:

static const std::shared_ptr< Base_Settings > & Default()
Returns global settings object.
Definition: Base_Settings.cxx:541
@ UseExceptions
Definition: Base_Settings.hxx:40

or set the environment variable CADEX_USE_EXCEPTIONS to 1. By default this setting is disabled and all the SDK facilities work just as they did prior to 3.5.3.

Note
This feature-flag only covers the exception classes derived from Base_Exception. There is a single exception that doesn't inherit from it – LicenseManager_LicenseError. This exception appeared in the SDK earlier and does not respect the feature-flag.

The API documentation contains the information about the available exception types and what exceptions are thrown by different functions. If you decide to enable exceptions, it's recommended to consult with it.

If you're looking for error messages see Logging Support.

Compatibility

It's expected that with time the list of exceptions will grow to contain the most useful error types. In CAD Exchanger 3 all the newly added exceptions will be gated by the Base_Settings::UseExceptions feature-flag. If you don't enable it, the standard binary compatibility guarantees apply. If you enable it, compatibility is not guaranteed as some functions that didn't throw before might start throwing. When you update CAD Exchanger we recommend checking the changelog and adding handlers for new exceptions.

C#, Java and Python

C#, Java and Python interfaces can also throw exceptions. The usage is the same as in C++: all one needs is to enable them by setting UseExceptions. The hierarchy of exceptions and the lists of exceptions thrown from each function are the same as in C++, so please consult the C++ documentation for specifics.