Mass++ Common Libraries v2.7.5
 All Classes Namespaces Files Functions Variables Enumerations Macros
Functions | Variables
ErrorCode.h File Reference

common error code definition More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

unsigned int errorcode (const char *errorName)
 get new error code More...
 
const char * errorstring (unsigned int errorCode)
 get error string for an existing error More...
 
void errorcleanup (void)
 deallocate error strings object
 

Variables

const unsigned int ERR_OK = errorcode( "ok" )
 
const unsigned int ERR_FILE_NOT_FOUND = errorcode( "file not found" )
 
const unsigned int ERR_FILE_OPEN_FAILED = errorcode( "file open failed" )
 
const unsigned int ERR_FILE_CLOSE_FAILED = errorcode( "file close failed" )
 
const unsigned int ERR_FILE_READ_FAILED = errorcode( "file read failed" )
 
const unsigned int ERR_FILE_WRITE_FAILED = errorcode( "file write failed" )
 
const unsigned int ERR_PATH_IS_DIRECTORY = errorcode( "path is a directory" )
 
const unsigned int ERR_ILLEGAL_FILE = errorcode( "illegal file" )
 
const unsigned int ERR_ILLEGAL_NAME = errorcode( "illegal name" )
 
const unsigned int ERR_ILLEGAL_VALUE = errorcode( "illegal value" )
 
const unsigned int ERR_NULL_POINTER = errorcode( "null pointer" )
 
const unsigned int ERR_DB = errorcode( "database" )
 
const unsigned int ERR_OTHER = errorcode( "other" )
 
const unsigned int ERR_FILE_PARMISSIONS_ILLEGAL = errorcode( "file permisions is illegal" )
 

Detailed Description

common error code definition

Author
S.Tanaka
Date
2006.07.11

Copyright(C) 2006-2014 Eisai Co., Ltd. All rights reserved.

Definition in file ErrorCode.h.

Function Documentation

unsigned int errorcode ( const char *  errorName)

get new error code

Parameters
errorNameerror name
Returns
error code

Definition at line 23 of file ErrorCode.cpp.

23  {
24  // static variable
25  static unsigned int maxErrorCode = 0;
26 
27  // create string object
28  std::string s = std::string( NVL( errorName, "" ) );
29 
30  // get error code
31  unsigned code = maxErrorCode;
32 
33  unsigned errorIndex = -1;
34 
35  if (pErrorList == NULL)
36  {
37  pErrorList = new std::vector<std::pair<std::string, unsigned int>>;
38  }
39 
40  for (int i = 0; (i < static_cast<int>(pErrorList->size())) && (errorIndex == -1); i++)
41  {
42  if ((*pErrorList)[i].first.compare(errorName) == 0)
43  {
44  errorIndex = i;
45  }
46  }
47 
48  if( errorIndex == -1 ) { // new error code
49  pErrorList->push_back(std::pair<std::string, unsigned int>(errorName, code));
50  maxErrorCode++;
51  }
52  else { // already exists
53  code = (*pErrorList)[errorIndex].second;
54  }
55 
56  return code;
57 }
#define NVL(checkVal, replaceVal)
Definition: CoreMacros.h:99
#define NULL
Definition: CoreMacros.h:18
const char* errorstring ( unsigned int  errorCode)

get error string for an existing error

Parameters
errorCodeerror code
Returns
error string

Definition at line 60 of file ErrorCode.cpp.

60  {
61 
62  unsigned errorIndex = -1;
63 
64  // get error string
65  for (int i = 0; (i < static_cast<int>(pErrorList->size())) && (errorIndex == -1); i++)
66  {
67  if ((*pErrorList)[i].second == errorCode)
68  {
69  errorIndex = i;
70  }
71  }
72 
73  if (errorIndex != -1)
74  {
75  return (*pErrorList)[errorIndex].first.c_str();
76  }
77  else
78  {
79  return "";
80  }
81 }

Variable Documentation

const unsigned int ERR_DB = errorcode( "database" )

DB error

Definition at line 72 of file ErrorCode.h.

const unsigned int ERR_FILE_CLOSE_FAILED = errorcode( "file close failed" )

It failed to close a file

Definition at line 48 of file ErrorCode.h.

const unsigned int ERR_FILE_NOT_FOUND = errorcode( "file not found" )

File is not found.

Definition at line 42 of file ErrorCode.h.

const unsigned int ERR_FILE_OPEN_FAILED = errorcode( "file open failed" )

It failed to open a file

Definition at line 45 of file ErrorCode.h.

const unsigned int ERR_FILE_PARMISSIONS_ILLEGAL = errorcode( "file permisions is illegal" )

File permissions is illegal

Definition at line 79 of file ErrorCode.h.

const unsigned int ERR_FILE_READ_FAILED = errorcode( "file read failed" )

It failed to read a file

Definition at line 51 of file ErrorCode.h.

const unsigned int ERR_FILE_WRITE_FAILED = errorcode( "file write failed" )

It failed to write a file

Definition at line 54 of file ErrorCode.h.

const unsigned int ERR_ILLEGAL_FILE = errorcode( "illegal file" )

File is illegal

Definition at line 60 of file ErrorCode.h.

const unsigned int ERR_ILLEGAL_NAME = errorcode( "illegal name" )

Name is illegal

Definition at line 63 of file ErrorCode.h.

const unsigned int ERR_ILLEGAL_VALUE = errorcode( "illegal value" )

Value is illegal

Definition at line 66 of file ErrorCode.h.

const unsigned int ERR_NULL_POINTER = errorcode( "null pointer" )

The pointer is null

Definition at line 69 of file ErrorCode.h.

const unsigned int ERR_OK = errorcode( "ok" )

OK

Definition at line 39 of file ErrorCode.h.

const unsigned int ERR_OTHER = errorcode( "other" )

etc

Definition at line 75 of file ErrorCode.h.

const unsigned int ERR_PATH_IS_DIRECTORY = errorcode( "path is a directory" )

The path is directory

Definition at line 57 of file ErrorCode.h.