![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Error Processing
General Error ProcessingThis chapter discusses the ASIS approach to error handling.
ASIS reports all operational errors by raising an exception.
Before an ASIS implementation raises one of the exceptions declared in package Asis.Exceptions, it sets these values to indicate the cause of the error:
- Status
- Diagnosis
The Status and Diagnosis values can be retrieved with Environment.Status and Environment.Diagnosis.
ASIS applications are encouraged to follow this same convention whenever they explicitly raise any ASIS exception, that is, they always record a Status and Diagnosis before raising the exception. Use Environment.Set_Status to set both values.
Whenever an exception is raised, the resulting Status will not be Not_An_Error. The possible values for Status are shown in Table 4 along with the associated contents of the Diagnosis string.
Note: Each ASIS implementation provides its own values for Diagnosis —— either Nil_Asis_String or some arbitrary text description of the error.
The following table shows Diagnosis information that might be provided by the vendor if Nil_Asis_String is not returned.
Exceptions in ASISAll ASIS subprograms catch, handle, and recover from all exceptions (with a when others => exception handler) and do one of the following:
- Propagate the exception if it is one defined by ASIS
- Set the Status and Diagnosis information to indicate what information is available for the unhandled exception (the minimum information being a Status of Unhandled_Exception_Error and a Diagnosis of Nil_Asis_String) and raise Asis_Failed
This attempts to ensure that the only exceptions propagated from an ASIS subprogram to a user's application are ASIS exceptions. There are at least the following cases where an ASIS implementation may not be able to prevent the raising or propagation of a non-ASIS exception:
- Storage_Error due to stack overflow during a call to ASIS from the application
- Constraint_Error due to being passed an uninitialized value (where the constraint check is performed automatically during copy-in of an in mode parameter or during copy-out of an in out mode parameter)
I/O Exceptions
The I/O interfaces, exported by the Asis.Ids package, are expected to raise the various predefined Ada I/O exceptions when appropriate —— for example, Io_Exceptions.Use_Error.
Exceptions from Enumeration Functions
ASIS functions that return enumeration values raise only these exceptions and no others:
- Asis_Inappropriate_Library in response to the use of unopened ASIS libraries
- Asis_Inappropriate_Compilation_Unit in response to the use of invalid ASIS compilation units
- Asis_Inappropriate_Element in response to the use of invalid elements
This prevents simple queries that ask for the kind of an element or ask if an element is of a certain variety from raising an exception simply because the argument is not of some constrained kind. These functions have no inappropriate argument kinds.
Unimplemented ASIS Features
The ASIS standard does not require that all vendors implement all features of ASIS. Hence, it is possible for your application to invoke an unimplemented ASIS feature. When this occurs, Asis_Failed is raised, Status is set to Not_Implemented_Error, and Diagnosis is also set. The minimal Diagnosis is Nil_Asis_String. Some implementations might provide a Diagnosis value that includes a description or name for the unimplemented functionality.
Exceptions Raised by ASIS
The following exceptions can be raised by ASIS:
- Asis_Failed
- Asis_Inappropriate_Compilation_Unit
- Asis_Inappropriate_Element
- Asis_Inappropriate_Library
- Asis_Inappropriate_Line
- Asis_Inappropriate_Line_Number
Asis_Failed
Raised by any ASIS routine that cannot complete its operation normally. This exception typically indicates a failure of, or a programmer error in, the ASIS implementation.
This is a catch-all exception that may be raised for different reasons in different ASIS implementations.
When Asis_Failed is raised, the implementation should provide at a minimum a Status of Internal_Error and a Diagnosis of Nil_Asis_String.
Asis_Inappropriate_Compilation_Unit
Raised when ASIS is passed a compilation unit that is invalid or inappropriate. This exception typically indicates that a programmer error has occurred in the application.
- Uninitialized or Nil_Compilation_Unit
- Compilation unit not an appropriate kind of unit for the operation
Asis_Inappropriate_Element
Raised when ASIS is given an element that is invalid or inappropriate. This exception typically indicates that a programmer error has occurred in the application.
- Uninitialized or Nil_Element
- Element not an appropriate kind of element for the operation
Asis_Inappropriate_Library
Raised when ASIS is passed a library that is inappropriate for the operation. This exception typically indicates that a programmer error has occurred in the application.
- Uninitialized or Nil_Library
- Dissociated library
- Library not open
Asis_Inappropriate_Line
Raised when ASIS is given a line that is invalid or inappropriate.
- Uninitialized or Nil_Line
- Line value has been dissociated (dangling pointer)
Asis_Inappropriate_Line_Number
Raised when ASIS is given a Line_Number value that is not appropriate. This exception typically indicates that a programmer error has occurred in the application.
- Uninitialized Line_Number
- Line number is out of range of valid text lines for Line_Element
Rational Software Corporation http://www.rational.com support@rational.com techpubs@rational.com Copyright © 1993-2002, Rational Software Corporation. All rights reserved. |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |