CTException Class

class CTException

Description

The CTException Class is the base exception handling class for the FairCom DB API C++ 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 C++ source file that generated the error
  • GetLineNbr(): Returns the line number of the C++ source file that generated the error.

 

CTException::CTException

Syntax

CTException(NINT ErrorCode)
CTException(NINT ErrorCode, pTEXT ErrorMsg)
CTException(NINT ErrorCode, pTEXT SourceFile, NINT LineNbr)
CTException(NINT ErrorCode, pTEXT ErrorMsg, pTEXT SourceFile, NINT 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

NINT GetErrorCode( )  const

Parameters

This method has no parameters.

Description

Returns the last error code.

Return

GetErrorCode() returns the last error code.

See also

GetErrorMsg(), GetSourceFile(), GetLineNbr()

 

CTException::GetErrorMsg

Syntax

pTEXT GetErrorMsg( )  const

Parameters

This method has no parameters.

Description

Returns a CTString 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
{
   pSession->Logon("FAIRCOMS", "ADMIN", "ADMIN");
   printf("\n\nSession Logon succesful!");
}
catch(CTException& err)
{
   printf("\n\n%d  %s",err.GetErrorCode(), err.GetErrorMsg());
}
 

See also

GetErrorCode(), GetSourceFile(), GetLineNbr()

 

CTException::GetLineNumber

Syntax

NINT GetLineNumber( )  const

Parameters

This method has no parameters.

Description

Returns the line number of the C++ 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

pTEXT GetSourceFile( ) const

Parameters

This method has no parameters.

Description

Returns the CTString object with the C++ 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()