Generated code - Handling exceptions

Preface

Exceptions are considered 'exceptional' in the runtime libraries and generated code. This means that exceptions are used to illustrate an exceptional state which has to be addressed. They're not used to report a semantic failure. An example of a semantic failure is the save of a single entity without recursion. This save can fail due to various reasons. The save logic in the template groups will return false in that case and not an exception: the action simply failed. If an error occurs in the code, due to input or a code error, the code does throw exceptions or will simply bubble up the exception. If the exception is an exception which should be handled locally, the runtime libraries or the generated code will try to handle the exception and only if nothing helps it will be passed upwards. This can sometimes mean that the exception is encapsulated in a custom exception to provide more information about the error caught, for example when a query failed, the complete query is included in the exception.

You should always check for return values if the method returns a return value, for example true or false as your primary result check. You should add try/catch clauses if you need local handling of the exceptions thrown, otherwise you can better bubble it up and handle it in a global exception handler routine. Because exceptions are only thrown in the case of an error (programmatic or via input), you don't have to add long exception catch clauses, as only in the case of an error an exception is thrown, which means you have to have error-recovery in place to successfully handle the error further.

Custom exceptions

Below are listed the custom exceptions as they're thrown by the generated code and runtime libraries. All exceptions are serializable and should be able to pass remoting boundaries. The exception classes are defined in the ORM Support classes library. See the reference manual for details about the classes. All custom exceptions are derived from the common base class ORMException.


LLBLGen Pro Runtime Framework v3.5 documentation. ©2012 Solutions Design bv