Error Handling

Error Handling in the eeGeo SDK

Error Handling

Some error cases are unavoidable, such as loss of network connectivity when obtaining critical data. The eeGeo SDK will notify you when this and other recoverable errors occur. This article covers how to handle errors correctly.

In this section:

Error Handling Policy

No Exception

The eeGeo SDK does not throw C++ exceptions and favours assertions as a error handling mechanism. As such, it should not be anticipated that the platform will throw any exceptions when faced with a critical error.

Any errors that are not critical to the platform but may be critical to your application, for example, a required local file is missing, should be handled by the application code accordingly.

Eegeo_ASSERT Macro

Assertions are used throughout the SDK by means of the Eegeo_ASSERT macro, which calls methods in the Eegeo::AssertHandler namespace. See the following use in the Route Simulation example:

Should the evaluation of the assertion be false, the SDK will terminate. Note, this will only happen in critical circumstances where execution of the SDK can not continue.

Assert Behaviour

Eegeo_ASSERTs will always terminate execution in the rare instances they occurs. However, it is possible to configure other behaviour, such as the logging of error messages or breaking on assertions. This can be done by setting the LogOnAssert and BreakOnAssert flags in the AssertHandler namespace.

Error Handling Classes


There are some cases where the SDK cannot function and offers the means to add functionality prior to termination, rather than asserting and terminating immediately. For example, this could occur if a API key is invalid or there is no network connection to download SDK critical resources. The latter of these cases should be rare as these resources are cached to the device after the first run.

This is achieved by implementing the IEegeoErrorHandler interface and passing an instance of its implementation into the EegeoWorld constructor.

See the following code snippet as an example:



Passing an implementation of this interface to the EegeoWorld constructor allows the custom error functionality to run:

It is important to note that regardless of the implementation of these methods, the situation in which they are called in the SDK is irrecoverable and your application should terminate with an appropriate message being displayed to the user.

Default Behaviour

If no implementation of the IEegeoErrorHandler interface is passed to EegeoWorld then the default behaviour in the above cases is to display a default popup dialog box.