PowerAda Exceptions

From OC Systems Wiki!
Jump to: navigation, search


Exceptions are errors that an Ada program detects while it runs. Section 11 of the RM95 describes the workings of exceptions within Ada.

With the PowerAda compiler, exceptions do not increase the time a program takes to run unless they are actually raised. This means you can write as many exception handlers as you want without sacrificing execution speed; however, the size of your code will still increase as you add more handlers or as you define more places where exceptions are explicitly raised. In some cases, the presence of exception checks may prevent some optimizations from being performed when the -G or -O compiler options are used.

Any exception handlers must exist somewhere within your code. If an exception occurs within the scope of a main program and you have not defined a handler for it, your program will end.

Note: Unhandled exceptions in task bodies only cause the task to end, not the entire program. When a program ends because of an unhandled exception, it displays the following information first:

  • The name of the exception.
  • A detailed reason for the exception, if available.
  • The name of the package where the exception occurred.
  • The line number where the exception occurred.
  • The line where the exception was last raised, if it was propagated.
  • A trace of the current active call chain, showing the line and compilation unit from which each procedure in the call traceback was called.