Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MsqError Class Reference

Used to hold the error state and return it to the application. More...

#include <MsqError.hpp>

Inheritance diagram for MsqError:

Classes

class  Setter
 
class  Trace
 One line of stack trace data. More...
 

Public Types

enum  ErrorCode {
  NO_ERROR = 0, UNKNOWN_ERROR, OUT_OF_MEMORY, INVALID_ARG,
  NOT_INITIALIZED, INVALID_STATE, FILE_ACCESS, FILE_FORMAT,
  PARSE_ERROR, IO_ERROR, INVALID_MESH, NO_PD_STORAGE_MODE,
  NOT_IMPLEMENTED, INTERNAL_ERROR, INTERRUPTED, TAG_ALREADY_EXISTS,
  TAG_NOT_FOUND, LAST_ERROR_CODE, NO_ERROR = 0, UNKNOWN_ERROR,
  OUT_OF_MEMORY, INVALID_ARG, NOT_INITIALIZED, INVALID_STATE,
  FILE_ACCESS, FILE_FORMAT, PARSE_ERROR, IO_ERROR,
  INVALID_MESH, NO_PD_STORAGE_MODE, NOT_IMPLEMENTED, INTERNAL_ERROR,
  INTERRUPTED, TAG_ALREADY_EXISTS, TAG_NOT_FOUND, LAST_ERROR_CODE
}
 Error codes. More...
 
enum  ErrorCode {
  NO_ERROR = 0, UNKNOWN_ERROR, OUT_OF_MEMORY, INVALID_ARG,
  NOT_INITIALIZED, INVALID_STATE, FILE_ACCESS, FILE_FORMAT,
  PARSE_ERROR, IO_ERROR, INVALID_MESH, NO_PD_STORAGE_MODE,
  NOT_IMPLEMENTED, INTERNAL_ERROR, INTERRUPTED, TAG_ALREADY_EXISTS,
  TAG_NOT_FOUND, LAST_ERROR_CODE, NO_ERROR = 0, UNKNOWN_ERROR,
  OUT_OF_MEMORY, INVALID_ARG, NOT_INITIALIZED, INVALID_STATE,
  FILE_ACCESS, FILE_FORMAT, PARSE_ERROR, IO_ERROR,
  INVALID_MESH, NO_PD_STORAGE_MODE, NOT_IMPLEMENTED, INTERNAL_ERROR,
  INTERRUPTED, TAG_ALREADY_EXISTS, TAG_NOT_FOUND, LAST_ERROR_CODE
}
 Error codes. More...
 
typedef msq_std::list< TraceStackTrace
 Container type used to store stack trace. More...
 
typedef msq_std::list< TraceStackTrace
 Container type used to store stack trace. More...
 

Public Member Functions

void clear ()
 resets error object to non-active state (no error). More...
 
bool error () const
 Check if an error has occured. More...
 
 operator bool () const
 Check if an error has occured. More...
 
 MsqError ()
 Initialize to cleared state. More...
 
virtual ~MsqError ()
 Destructor - empty but must declar virtual destrucor if virtual functions. More...
 
ErrorCode error_code () const
 Get error code. More...
 
const char * error_message () const
 Get error message. More...
 
const StackTracestack () const
 Get stack trace. More...
 
virtual bool push (const char *function, const char *file, int line)
 Add to back-trace of call stack. More...
 
virtual bool set_error (ErrorCode num, const char *msg=0)
 Initialize the error object with the passed data. More...
 
void clear ()
 resets error object to non-active state (no error). More...
 
bool error () const
 Check if an error has occured. More...
 
 operator bool () const
 Check if an error has occured. More...
 
 MsqError ()
 Initialize to cleared state. More...
 
virtual ~MsqError ()
 Destructor - empty but must declar virtual destrucor if virtual functions. More...
 
ErrorCode error_code () const
 Get error code. More...
 
const char * error_message () const
 Get error message. More...
 
const StackTracestack () const
 Get stack trace. More...
 
virtual bool push (const char *function, const char *file, int line)
 Add to back-trace of call stack. More...
 
virtual bool set_error (ErrorCode num, const char *msg=0)
 Initialize the error object with the passed data. More...
 

Static Public Member Functions

static Setter setter (MsqError &err, const char *function, const char *file, int line)
 
static Setter setter (MsqError &err, const char *function, const char *file, int line)
 

Private Attributes

ErrorCode errorCode
 
msq_std::string errorMessage
 
StackTrace stackTrace
 

Detailed Description

Used to hold the error state and return it to the application.

Author
Jason Kraftcheck
Date
2004-09-17

Used to hold error state and related information. Internal Mesquite code should access this object via the MSQ_SETERR and MSQ_CHKERR macros.

For applications, the cast-to-bool operator and << operator are provided for convenient, if simple access to this data. E.g.: if (err) cout << err << endl;

There are two options for an application to gain more detailed access to the error data. The application may either access the data stored in this class via the provided methods or subclass MsqError, overriding set_error and push to handle the error data as it is generated.

Definition at line 106 of file includeLinks/MsqError.hpp.

Member Typedef Documentation

typedef msq_std::list<Trace> StackTrace

Container type used to store stack trace.

Return type for stack

Definition at line 173 of file includeLinks/MsqError.hpp.

typedef msq_std::list<Trace> StackTrace

Container type used to store stack trace.

Return type for stack

Definition at line 173 of file src/Misc/MsqError.hpp.

Member Enumeration Documentation

enum ErrorCode

Error codes.

Enumerator
NO_ERROR 

no error

UNKNOWN_ERROR 

unknown error occured

OUT_OF_MEMORY 

unable to allocate the necessary memory

INVALID_ARG 

invalid function argument passed

NOT_INITIALIZED 

object not initialized

INVALID_STATE 

object is in an invalid state

FILE_ACCESS 

File cannot be opened/created.

FILE_FORMAT 

Wrong file type.

PARSE_ERROR 

Error parsing input (or input file)

IO_ERROR 

An I/O error occured (e.g.

read from file failed.)

INVALID_MESH 

The mesh is invalid.

NO_PD_STORAGE_MODE 

no storage mode chosen within PatchData

NOT_IMPLEMENTED 

requested functionality is not (yet) implemented

INTERNAL_ERROR 

A bug in Mesquite.

INTERRUPTED 

Application or user interrupted operation.

TAG_ALREADY_EXISTS 

Attempt to create tag that already exists.

TAG_NOT_FOUND 

Specified tag does not exist.

LAST_ERROR_CODE 
NO_ERROR 

no error

UNKNOWN_ERROR 

unknown error occured

OUT_OF_MEMORY 

unable to allocate the necessary memory

INVALID_ARG 

invalid function argument passed

NOT_INITIALIZED 

object not initialized

INVALID_STATE 

object is in an invalid state

FILE_ACCESS 

File cannot be opened/created.

FILE_FORMAT 

Wrong file type.

PARSE_ERROR 

Error parsing input (or input file)

IO_ERROR 

An I/O error occured (e.g.

read from file failed.)

INVALID_MESH 

The mesh is invalid.

NO_PD_STORAGE_MODE 

no storage mode chosen within PatchData

NOT_IMPLEMENTED 

requested functionality is not (yet) implemented

INTERNAL_ERROR 

A bug in Mesquite.

INTERRUPTED 

Application or user interrupted operation.

TAG_ALREADY_EXISTS 

Attempt to create tag that already exists.

TAG_NOT_FOUND 

Specified tag does not exist.

LAST_ERROR_CODE 

Definition at line 115 of file includeLinks/MsqError.hpp.

115  {
116  NO_ERROR = 0,
117  UNKNOWN_ERROR,
118  OUT_OF_MEMORY,
119  INVALID_ARG ,
121  INVALID_STATE,
122  FILE_ACCESS,
123  FILE_FORMAT,
124  PARSE_ERROR,
125  IO_ERROR,
126  INVALID_MESH,
130  INTERRUPTED,
132  TAG_NOT_FOUND,
134  };
An I/O error occured (e.g.
unable to allocate the necessary memory
requested functionality is not (yet) implemented
Attempt to create tag that already exists.
invalid function argument passed
Application or user interrupted operation.
File cannot be opened/created.
Specified tag does not exist.
object is in an invalid state
no storage mode chosen within PatchData
Error parsing input (or input file)
enum ErrorCode

Error codes.

Enumerator
NO_ERROR 

no error

UNKNOWN_ERROR 

unknown error occured

OUT_OF_MEMORY 

unable to allocate the necessary memory

INVALID_ARG 

invalid function argument passed

NOT_INITIALIZED 

object not initialized

INVALID_STATE 

object is in an invalid state

FILE_ACCESS 

File cannot be opened/created.

FILE_FORMAT 

Wrong file type.

PARSE_ERROR 

Error parsing input (or input file)

IO_ERROR 

An I/O error occured (e.g.

read from file failed.)

INVALID_MESH 

The mesh is invalid.

NO_PD_STORAGE_MODE 

no storage mode chosen within PatchData

NOT_IMPLEMENTED 

requested functionality is not (yet) implemented

INTERNAL_ERROR 

A bug in Mesquite.

INTERRUPTED 

Application or user interrupted operation.

TAG_ALREADY_EXISTS 

Attempt to create tag that already exists.

TAG_NOT_FOUND 

Specified tag does not exist.

LAST_ERROR_CODE 
NO_ERROR 

no error

UNKNOWN_ERROR 

unknown error occured

OUT_OF_MEMORY 

unable to allocate the necessary memory

INVALID_ARG 

invalid function argument passed

NOT_INITIALIZED 

object not initialized

INVALID_STATE 

object is in an invalid state

FILE_ACCESS 

File cannot be opened/created.

FILE_FORMAT 

Wrong file type.

PARSE_ERROR 

Error parsing input (or input file)

IO_ERROR 

An I/O error occured (e.g.

read from file failed.)

INVALID_MESH 

The mesh is invalid.

NO_PD_STORAGE_MODE 

no storage mode chosen within PatchData

NOT_IMPLEMENTED 

requested functionality is not (yet) implemented

INTERNAL_ERROR 

A bug in Mesquite.

INTERRUPTED 

Application or user interrupted operation.

TAG_ALREADY_EXISTS 

Attempt to create tag that already exists.

TAG_NOT_FOUND 

Specified tag does not exist.

LAST_ERROR_CODE 

Definition at line 115 of file src/Misc/MsqError.hpp.

115  {
116  NO_ERROR = 0,
117  UNKNOWN_ERROR,
118  OUT_OF_MEMORY,
119  INVALID_ARG ,
121  INVALID_STATE,
122  FILE_ACCESS,
123  FILE_FORMAT,
124  PARSE_ERROR,
125  IO_ERROR,
126  INVALID_MESH,
130  INTERRUPTED,
132  TAG_NOT_FOUND,
134  };
An I/O error occured (e.g.
unable to allocate the necessary memory
requested functionality is not (yet) implemented
Attempt to create tag that already exists.
invalid function argument passed
Application or user interrupted operation.
File cannot be opened/created.
Specified tag does not exist.
object is in an invalid state
no storage mode chosen within PatchData
Error parsing input (or input file)

Constructor & Destructor Documentation

MsqError ( )
inline

Initialize to cleared state.

Definition at line 145 of file includeLinks/MsqError.hpp.

~MsqError ( )
virtual

Destructor - empty but must declar virtual destrucor if virtual functions.

Definition at line 82 of file Misc/MsqError.cpp.

82 {}
MsqError ( )
inline

Initialize to cleared state.

Definition at line 145 of file src/Misc/MsqError.hpp.

virtual ~MsqError ( )
virtual

Destructor - empty but must declar virtual destrucor if virtual functions.

Member Function Documentation

void clear ( )

resets error object to non-active state (no error).

Definition at line 150 of file Misc/MsqError.cpp.

References MsqError::errorCode, MsqError::errorMessage, MsqError::NO_ERROR, and MsqError::stackTrace.

Referenced by ParameterSet::generic_add_parameter(), and MeshImpl::read_vtk().

151 {
153  // MS VC6 doesn't have string::clear()!
154  errorMessage.resize(0);
155  stackTrace.clear();
156 }

Here is the caller graph for this function:

void clear ( )

resets error object to non-active state (no error).

bool error ( ) const
inline

Check if an error has occured.

Definition at line 140 of file includeLinks/MsqError.hpp.

References MsqError::errorCode, and MsqError::NO_ERROR.

Referenced by MsqPrintError::~MsqPrintError().

Here is the caller graph for this function:

bool error ( ) const
inline

Check if an error has occured.

Definition at line 140 of file src/Misc/MsqError.hpp.

References MsqError::errorCode, and MsqError::NO_ERROR.

ErrorCode error_code ( ) const
inline

Get error code.

Definition at line 155 of file includeLinks/MsqError.hpp.

References MsqError::errorCode.

Referenced by Mesquite::operator<<().

155 { return errorCode; }

Here is the caller graph for this function:

ErrorCode error_code ( ) const
inline

Get error code.

Definition at line 155 of file src/Misc/MsqError.hpp.

References MsqError::errorCode.

155 { return errorCode; }
const char * error_message ( ) const

Get error message.

Definition at line 45 of file Misc/MsqError.cpp.

References MsqError::errorCode, MsqError::errorMessage, and MsqError::LAST_ERROR_CODE.

Referenced by Mesquite::operator<<().

46 {
47  static const char* const error_messages[] = {
48  "No Error",
49  "<unknown>",
50  "Out of memory",
51  "Invalid argument",
52  "Data not initialized",
53  "Invalid state",
54  "File access error",
55  "File format error",
56  "Syntax error",
57  "I/O error",
58  "Invalid mesh",
59  "No storage mode for PatchData",
60  "Not implemented",
61  "Internal error",
62  "Interrupted",
63  "Duplicate tag name",
64  "Tag not found",
65  "Invalid Error Code"
66  };
67 
68  /* If this is ever false, it should be caught by a unit test.
69  Do an assert here so the unit test fails.
70  This asserts that all error codes have a string in the above list. */
71  assert( sizeof(error_messages) == sizeof(char*) * (LAST_ERROR_CODE+1) );
72 
73  if (!errorMessage.empty())
74  return errorMessage.c_str();
75 
76  if (errorCode >= 0 && errorCode < LAST_ERROR_CODE)
77  return error_messages[errorCode];
78 
79  return error_messages[LAST_ERROR_CODE];
80 }

Here is the caller graph for this function:

const char* error_message ( ) const

Get error message.

operator bool ( ) const
inline

Check if an error has occured.

Definition at line 142 of file src/Misc/MsqError.hpp.

References MsqError::errorCode, and MsqError::NO_ERROR.

operator bool ( ) const
inline

Check if an error has occured.

Definition at line 142 of file includeLinks/MsqError.hpp.

References MsqError::errorCode, and MsqError::NO_ERROR.

virtual bool push ( const char *  function,
const char *  file,
int  line 
)
virtual

Add to back-trace of call stack.

Called by MSQ_CHKERR. Must always return true.

bool push ( const char *  function,
const char *  file,
int  line 
)
virtual

Add to back-trace of call stack.

Called by MSQ_CHKERR. Must always return true.

Definition at line 130 of file Misc/MsqError.cpp.

References MsqError::stackTrace.

Referenced by MsqError::Setter::set().

131 {
132  stackTrace.push_back( Trace(function, file, line) );
133  return true;
134 }

Here is the caller graph for this function:

bool set_error ( ErrorCode  num,
const char *  msg = 0 
)
virtual

Initialize the error object with the passed data.

Definition at line 136 of file Misc/MsqError.cpp.

References MsqError::errorCode, MsqError::errorMessage, MsqError::NO_ERROR, and MsqError::stackTrace.

Referenced by MsqError::Setter::set().

137 {
138  errorCode = num;
139  stackTrace.clear();
140 
141  if (msg)
142  errorMessage = msg;
143  else
144  // MS VC6 doesn't have string::clear()!
145  errorMessage.resize(0);
146 
147  return num != NO_ERROR;
148 }

Here is the caller graph for this function:

virtual bool set_error ( ErrorCode  num,
const char *  msg = 0 
)
virtual

Initialize the error object with the passed data.

static Setter setter ( MsqError err,
const char *  function,
const char *  file,
int  line 
)
inlinestatic

Definition at line 213 of file includeLinks/MsqError.hpp.

214  { return Setter( err, function, file, line ); }
static Setter setter ( MsqError err,
const char *  function,
const char *  file,
int  line 
)
inlinestatic

Definition at line 213 of file src/Misc/MsqError.hpp.

214  { return Setter( err, function, file, line ); }
const StackTrace& stack ( ) const
inline

Get stack trace.

Definition at line 176 of file includeLinks/MsqError.hpp.

References MsqError::stackTrace.

Referenced by Mesquite::operator<<().

176 { return stackTrace; }

Here is the caller graph for this function:

const StackTrace& stack ( ) const
inline

Get stack trace.

Definition at line 176 of file src/Misc/MsqError.hpp.

References MsqError::stackTrace.

176 { return stackTrace; }

Member Data Documentation

msq_std::string errorMessage
private
StackTrace stackTrace
private

The documentation for this class was generated from the following files: