API Guides > ConceptRT 3.x
How to find programming error source

Standard diagnostic

ConceptRT exception mechanism enables us to diagnose the source of an error.

By default (without try...catch block) a wrong code such as :

SafeArray<Int32, 10> data;
data[10]; // line that is wrong.

would print out the following message on the console :

ErrorManagementStandardOutput.png

As shown in the console, the Error ID, a message and the throw line context help to find out what could be the source of the error.

Find the error source in your application

It could be useful to see the stack trace to find which line in your application is causing the error. There are two ways to do that:

See the complete code example

With MS Visual Studio

Visual Studio offers an exception detection mechanism to break your application where a line is throwing an exception. In order to activate this mechanism open the exceptions menu :

ErrorManagementVisualStudio.png

Then activate the C++ exceptions detection :

ErrorManagementVisualStudioExceptions.png

Once the application is launched in debug. The following window appears :

ErrorManagementVisualStudioFirstChanceExceptions.png

Break can be done in order to see the stack trace :

ErrorManagementVisualStudioStackTrace.png

On any debugger (allow filter)

A function or method can be branched to the exception mechanism. By this approach a break point can be put to see the stack trace. Moreover it is possible to filter on a specific error ID.

This is an example of function that can be branch :

// function prototype that can be used for tracing thrown RT exception
void OnException(RTException & e)
{
// put a break point here to find wich line throws an exception in your code.
if (e.GetErrorId() == RT_ERROR_OUT_OF_BOUND_INDEX)
{
int t = 0;
}
}

With the following code in your application the function or method can be branched to the mechanism.

// Code to branch a function on the event of thrown RT exception
DelegateFunction<RTException &> delegateOnException(OnException);

Once the code launches in debug with a break point, the application will stop on the line that causes the error.

ErrorManagementFindSource.png

See the complete code example