casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Example showing how to use the class Error

The codes using the Error class must include its header file.

To illustrate how to use this class we take here an example defining a class Array with a constraint about a maximum index.

In the test program we begin by showing the default critical limit for acceptable errors:

An array is declared and it is populated by integers for indices from 0 to 100. The opperator [] generate an Error throwing it if the index exceeds the maximum allowed limit, we insert the loop in a try section. When the index j exceeds the upper limit in the indexing, an Error is thrown unless this type type of errors is acceptable.

The out-of-range indexing in the [] operator methods having been declared to be SERIOUS, when j exceeds the maximum size allowed, its severity, SERIOUS (see the method []) is just at the critical when the error become unacceptable. Hence an Error exception is thrown.

The execution proceeds; the following test attests that this error was considered as acceptable:

We now repeat this scenario triggering with the same error but before that we test with a tolerence which is more constraining: any error will be thrown only when it severity reach the FATAL limit: setAcceptableLevel

The scenario is now repeated:

The Error is not catched because with this new contextthe error which is still SERIOUS is considered as acceptable.