Description
The CTException Class is the base exception handling class for the FairCom DB API .NET layer. It is used to throw an error message, when one exception occurs.
Preconditions
This class should be used where an error or unexpected behavior may occur. The error will throw an exception.
CTException Methods
Constructor / Destructor
- CTException(): Creates a CTException object, and retrieves the error code only
- ~CTException(): Destroys a CTException object and resets all the dependent objects
Error Handling
- GetErrorCode(): Returns the last error code
- GetErrorMsg(): Returns the last error message
- GetSourceFile(): Returns the source file that generated the error
- GetLineNbr(): Returns the line number of the source file that generated the error.
CTException.CTException
Syntax
CTException(int ErrorCode)
CTException(int ErrorCode, string ErrorMsg)
CTException(int ErrorCode, sbyte* SourceFile, int LineNbr)
CTException(int ErrorCode, sbyte* ErrorMsg, sbyte* SourceFile, int LineNbr)
Parameters
- ErrorCode [out] The error code
- ErrorMsg [out] The error message
- SourceFile [out] The source file where the error occurred
- LineNbr [out] The line number where error occurred
Description
This is the constructor for the CTException class.
See Also
~CTException()
CTException.~CTException
Syntax
~CTException
Parameters
The destructor has no parameters.
Description
This is the destructor for the CTException class.
See Also
CTException()
CTException.GetErrorCode
Syntax
int GetErrorCode( )
Parameters
This method has no parameters.
Description
Returns the last error code.
Return
GetErrorCode() returns the last error code.
See Also
GetErrorMsg(), GetLineNbr(), GetSourceFile()
CTException.GetErrorMsg
Syntax
String GetErrorMsg( )
Parameters
This method has no parameters.
Description
Returns a String object with the last error message. If the error message is not available, GetErrorMsg() returns an empty string.
Return
GetErrorMsg() returns the last error message.
Example
try
{
aSession.Logon("FAIRCOMS", "ADMIN", "ADMIN");
Console.Write("\n\nSession Logon succesful!");
}
catch(CTException err)
{
Console.Write("\n\n{0} {1}",err.GetErrorCode(), err.GetErrorMsg());
}
See Also
GetErrorCode(), GetLineNbr(), GetSourceFile()
CTException.GetLineNumber
Syntax
int GetLineNumber( )
Parameters
This method has no parameters.
Description
Returns the line number of the source file that generated the error, or zero if no line number is available.
Return
GetLineNumber() returns the line where the last error happened.
See Also
GetErrorCode(), GetErrorMsg(), GetSourceFile()
CTException.GetSourceFile
Syntax
String GetSourceFile( )
Parameters
This method has no parameters.
Description
Returns the String object with the source file (including path) that generated the last error. If the source file is not available, GetSourceFile() returns an empty string.
Return
GetSourceFile() returns the source file where the last error happened.
See Also
GetErrorCode(), GetErrorMsg(), GetLineNbr()