Class Name:
|
HL7PlusException
|
HL7+ Category:
|
Unrestricted
|
Description:
|
General error handling and reporting object class used in public object classes
|
The HL7PlusException object class is one that you are free to use yourself if you like. In HL7+ it is used in the public object classes wherever possible to indicate that an exception has occurred but where we don't wish to throw an actual runtime exception into YOUR code. If you use an HL7PlusUtilies object to read a simple text file into a String using the ReadTextFile() method for example:
*All example code is in Visual Basic.Net
Dim oUtils As New HL7PlusUtilities
Call the method using a bad file name
Dim x As String = oUtils.ReadTextFile("C:\BadFileName.txt")
At this point x is an empty string ("") and there has been no runtime exception thrown. However you can query oUtils.LastException to determine if the file was really empty OR if something else happened.
If x.Length = 0 Then
If oUtils.LastException.IsException Then
MessageBox.Show(oUtils.LastException.ExtendedErrorMessage)
End If
End If
IMPORTANT: All of the HL7+ public object classes that use the HL7PlusException object also extend it a little bit by aliasing some of the calls with shorthand so that the following example is IDENTICAL to the one above.
If x.Length = 0 Then
If oUtils.IsError Then
MessageBox.Show(oUtils.LastError)
End If
End If
|
Name
|
Data Type
|
Description
|
ExceptionMessage
|
String
|
The error message
|
ExceptionMethod
|
String
|
The internal method name which generated the HL7PlusException
|
ExceptionNumber
|
Int32
|
The exception number
|
ExtendedErrorMessage
|
String
|
An extended String error message which will include ExceptionMessage, Method and Number with labels and newlines for readability.
|
IsException
|
Boolean
|
Indicates whether there is an ExceptionMessage present (ExceptionMessage.Length > 0)
|
|
Method:
|
Clear()
|
Paramters:
|
None
|
Return Value:
|
N/A
|
Description:
|
Clears the HL7PlusException.
|
Method:
|
Copy()
|
Paramters:
|
None
|
Return Value:
|
HL7PlusException object
|
Description:
|
Returns a copy of the object as a new HL7PlusException.
|
Method:
|
SetException(oException) + 4 overloads
SetException(strMessage)
SetException(strMessage, strMethod)
SetException(strMessage, strMethod, intExceptionNumber)
SetException(oSystemException, strMethod, intExceptionNumber)
|
Paramters:
|
1. oException - HL7PlusException object
1. strMessage - String - ExceptionMessage
1. oSystemException - General .Net System Exception
2. strMethod - String - ExceptionMethod
3. intExceptionNumber - Integer - ExceptionNumber
|
Return Value:
|
N/A
|
Description:
|
Sets the HL7PlusException object internal values.
Programming NOTE: Calling HL7PlusException.SetException("") is identical to calling HL7PlusException.Clear()
|
|
In the HL7+ public object classes (whether restricted, unrestricted, or partially restricted) there is a uniform implementation of the HL7PlusException class so that every object class has the following public properties and methods.
LastException
|
HL7PlusException
|
A read-only instance of the internal HL7PlusException object
|
IsError
|
Boolean
|
Returns LastException.IsException
|
LastError
|
String
|
Returns LastException.ExtendedErrorMessage
|
ClearErrors()
|
N/A
|
Calls LastException.Clear()
|
Programming Note: In the public classes we do not expose any of the Set features of the HL7PlusException object but you can set the exception manually by calling one of the LastException.SetException() methods.
|