Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

CTError Class Reference
[Status and error classes]

This class can be used to flag errors. More...

#include <cterror.h>

List of all members.

Public Member Functions

 CTError (const string &where, unsigned char code, unsigned char subcode1, unsigned char subcode2, const string &info="", const string &explanation="")
 CTError (const string &where, const CTError &err)
 CTError ()
 ~CTError ()
bool isOk (unsigned char ad1=0, unsigned char ad2=0)
const string & where () const
int code () const
int subcode1 () const
int subcode2 () const
const string & info () const
const string & explanation () const
string errorString ()
const string & reportedFrom () const


Detailed Description

This class can be used to flag errors.

You can use this one to return an error code or you can throw an object of this class. This class holds information about errors, like

Author:
Martin Preuss<martin@libchipcard.de>


Constructor & Destructor Documentation

CTError::CTError const string &  where,
unsigned char  code,
unsigned char  subcode1,
unsigned char  subcode2,
const string &  info = "",
const string &  explanation = ""
 

Use this constructor if an error occurred.

Author:
Martin Preuss<martin@libchipcard.de>
Parameters:
where the location of the error, e.g. "CTError::isOk()"
info additional information about the error.
code error code, this can be one defined in CTTerminal, like:
  • k_CTERROR_INVALID
  • k_CTERROR_CT
  • k_CTERROR_TRANS
  • k_CTERROR_MEMORY
  • k_CTERROR_HTSI
subcode1 this is the first CTAPI return code. this and subcode2 are returned if the code shows "k_CTERROR_OK". This code holds the major code, while subcode2 is more specific about the error. (SW1)
subcode2 this is the second CTAPI return code (SW2)
info additional information
explanation Here you can explan the error. If this is omitted then this class will try to provide an explanation of its own.

CTError::CTError const string &  where,
const CTError err
 

CTError::CTError  ) 
 

Use this constructor if NO error occurred. This way you can return more complex return values. The caller may ask this object with isOk() to determine if an error occurred.

Author:
Martin Preuss<martin@libchipcard.de>

CTError::~CTError  ) 
 


Member Function Documentation

int CTError::code  )  const [inline]
 

Returns the error code

Author:
Martin Preuss<martin@libchipcard.de>

string CTError::errorString  ) 
 

Returns a short error string containing all important information.

Author:
Martin Preuss<martin@libchipcard.de>

const string& CTError::explanation  )  const [inline]
 

Returns a short explanation of tis error.

Author:
Martin Preuss<martin@libchipcard.de>

const string& CTError::info  )  const [inline]
 

Returns additional info about the error.

Author:
Martin Preuss<martin@libchipcard.de>

bool CTError::isOk unsigned char  ad1 = 0,
unsigned char  ad2 = 0
 

Tells you if this object shows an error or if all was ok. You may give additional values for subcode1 and subcode2 which are to be treated "OK". This is needed, when checking the result of CTCard::closeCard(), which sometimes returns SW1=0x62, thus showing that no card is inserted. Well, this is an error on all other methods, but when calling closeCard() this result is desired. So for checking the result of closeCard() use this: err.isOk(0x62);

Parameters:
ad1 subcode1 to be treated ok
ad2 subcode2 to be treated ok when occuring together with ad1
Author:
Martin Preuss<martin@libchipcard.de>
Returns:
true if there was no error, false otherwise

const string& CTError::reportedFrom  )  const [inline]
 

Returns the path of methods/functions which reported this error.

int CTError::subcode1  )  const [inline]
 

Returns subcode1

Author:
Martin Preuss<martin@libchipcard.de>

int CTError::subcode2  )  const [inline]
 

Returns subcode2

Author:
Martin Preuss<martin@libchipcard.de>

const string& CTError::where  )  const [inline]
 

Return the location of the error, e.g. "CTError::CTError()".

Author:
Martin Preuss<martin@libchipcard.de>


The documentation for this class was generated from the following file:
Generated on Sat Feb 11 15:20:28 2006 for libchipcard by  doxygen 1.4.2