Exception management, Exception handling, Exception handling 20 – Google Apps Security and Compliance Services Web Services Application Programming Interface Guide, Early Access Version 1.5 User Manual
Page 23

20
Message Security and Compliance Application Programming Interface Guide RELEASE EA version 1.5
MalformedKeyException -- This exception is thrown if the key was not
constructed properly. For more information for the MalformedKeyException, see
“Exceptions” on page 21.
NoSuchKeyException -- This exception is thrown if the key is constructed
properly but is not valid. For more information for the NoSuchKeyException, see
“Exceptions” on page 21.
Exception Management
Exceptions signal an error condition that has changed the expected flow of your
application. Exceptions can occur at any place in the system and at any time.
Depending upon the exception, either your application resolves the error or the
exception is critical enough to stop your application from running. For example, if
a user enters the wrong password, your application does not stop running. The
application error handling logic aborts the password authentication operation and
queries the user for the correct password. If your API license key is not valid, the
web service part of your application is halted. If a lower-level transport exception
occurs, your application should stop.
After an exception is thrown, it is important for your application to validate the
state of the data. At the time when an exception is thrown and an operation is
aborted, value assignments may not have been set. It depends on the exception.
For example, do not assume an operation has successfully deleted, added, or
modified an organization after an exception is thrown. Your application has to
check the data.
Most C# and Java IDEs have automated exception handling features that help
you identify and fix exceptions during your development and testing cycles.
Exception Handling
The goal of an application is to handle exceptions so that the operation aborts but
the application itself does not stop running whenever possible.
•
Transport-level exceptions -- Usually, these are serious errors. The
application should stop running.
•
Operation-level exceptions -- For exceptions where a request can not be
fulfilled, the application should catch the exception and handle it. For
example, if a user’s name can not be found, ask the user to enter another
name.