Exception object
Previous  Next

The Exception object provides the following methods and properties. The first thing that the exception handling code should do is assign the exception returned by B4PObject(6) to the ControlRef property of an Exception object. The type of error may then be determined and appropriate action taken. An application will typically only ever need one Exception object.


Methods

Clear : Clears the saved exception within the Exception object. As exceptions are entirely handled within the Sub where they occur the presence of an exception in an Exception object will show that an error has occurred in one or more Subs called by a Sub. This may help in signalling the occurrence of errors back down the call chain of Subs.

ThrowNew(message As String) : Causes a new exception of type System._B4PPCException to be thrown with the specified message. Any existing saved exception is included in the the new exceptions' InnerException. This may be used to transfer execution within a Sub to its own exception handling code where it is found that an earlier error has occurred.

ReThrow : Causes the saved exception to be re-thrown within the current Sub. This may be used to transfer execution within a Sub to its own exception handling code if it is found that an earlier error has occurred. If there is no saved exception then a _B4PPCException is thrown with a "No saved exception" message.

New1 : Creates a new Exception object.

CreateNew(message As String) : Returns a new exception object of type System._B4PPCException with the specified message. Any existing saved exception is included in the the new exceptions' InnerException. This could be used to assign a custom exception to ControlRef without actually throwing an exception within the Sub's code so that an earlier calling Sub, by checking Saved, could see that an error occurred in a called Sub.This also might be useful to a future library to obtain a B4PPC specific Exception object.  Note that this does not save the new exception internally. The return value must be assigned to the ControlRef property of an Exception object or the Value property of an Door library Object (or something else) in order to save it.


Properties

I signifies readable, O signifies settable.

ControlRef: Exception [I/O] : Returns a reference to the saved exception (or null if none) or saves a reference to a .NET exception object. Normally this is obtained from the B4PObject(6) but can be obtained from CreateNew.
 e.g .Exception1.ControlRef = B4PObject(6).
Exception1.ControlRef = .Exception1.CreateNew

InnerControlRef: Exception [I] : Returns a reference to the InnerException  of the saved exception or null if none. This property is read-only and might be needed if it is required to walk back a chain of exceptions.

Name: String [I] : Returns the name of the saved exception. This is the rightmost part of the type name of the exception. Returns a null string if no exception is saved.

FullName: String [I] : Returns the type name of the saved exception. This typically consists of several parts, separated by a "." the first part being "System". Returns a null string if no exception is saved.

Message: String [I] : Returns the message associated with the saved exception. Returns a null string if no exception is saved.

Saved: Boolean [I] : Returns true if there is a exception saved within the Exception object otherwise returns false.

StackTrace: String [I] : Provided by the Exceptions2 library only. Returns a string containing the stack trace for the exception. Returns a null string if no exception is saved.

DllVersion : Double [I] : Returns the version number of this library.

InnerName: String [I] : Returns the name of the InnerException of the saved exception if any. This is the rightmost part of the type name of the exception. Returns a null string if no exception is saved or there is no inner exception.

InnerFullName: String [I] : Returns the type name of the InnerException of the saved exception if any. This typically consists of several parts, separated by a "." the first part being "System". Returns a null string if no exception is saved or there is no inner exception.

InnerMessage: String [I] : Returns the message associated with the InnerException of the saved exception if any. Returns a null string if no exception is saved or there is no inner exception.

InnerSaved: Boolean [I] : Returns true if there is an inner exception saved within the Exception object otherwise returns false.

InnerStackTrace: String [I] : Provided by the Exceptions2 library only. Returns a string containing the stack trace for the inner exception.  Returns a null string if no exception is saved or there is no inner exception.