MOAB: Mesh Oriented datABase  (version 5.2.1)
MBMesquite::MsqError Class Reference

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

#include <MsqError.hpp>

+ Inheritance diagram for MBMesquite::MsqError:
+ Collaboration diagram for MBMesquite::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, UNSUPPORTED_ELEMENT, PARALLEL_ERROR, BARRIER_VIOLATED,
  LAST_ERROR_CODE
}
 Error codes. More...
typedef std::list< TraceStackTrace

Public Member Functions

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

Static Public Member Functions

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

Private Attributes

ErrorCode errorCode
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 101 of file MsqError.hpp.


Member Typedef Documentation

Container type used to store stack trace. Return type for stack()

Definition at line 181 of file MsqError.hpp.


Member Enumeration Documentation

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

UNSUPPORTED_ELEMENT 

the element type is not supported.

PARALLEL_ERROR 

an error occurred in parallel >

BARRIER_VIOLATED 

barruer violated when processing barrier Target Metric

LAST_ERROR_CODE 

Definition at line 110 of file MsqError.hpp.

    {
        NO_ERROR = 0,        /**< 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 */
        UNSUPPORTED_ELEMENT, /**< the element type is not supported. */
        PARALLEL_ERROR,      /**< an error occurred in parallel > */
        BARRIER_VIOLATED,    /**< barruer violated when processing barrier Target Metric */
        LAST_ERROR_CODE
    };

Constructor & Destructor Documentation

Initialize to cleared state.

Definition at line 150 of file MsqError.hpp.

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

Definition at line 81 of file MsqError.cpp.

{}

Member Function Documentation

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

Definition at line 145 of file MsqError.cpp.

References errorCode, errorMessage, NO_ERROR, and stackTrace.

Referenced by FileTokenizerTest::boolean_test(), MBMesquite::DomainClassifier::classify_by_tag(), MBMesquite::MeshImplTags::create(), LinearMappingFunctionTest::do_coeff_test(), LinearMappingFunctionTest::do_deriv_test(), FileTokenizerTest::double_test(), MBMesquite::NonGradient::evaluate(), MBMesquite::ObjectiveFunction::evaluate_with_gradient(), MBMesquite::PlanarDomain::fit_vertices(), MBMesquite::geom_classify_vertices(), MBMesquite::ConjugateGradient::get_step(), MBMesquite::QualityAssessor::get_tag(), MBMesquite::TargetWriter::get_tag_handle(), MBMesquite::TagVertexMesh::initialize(), FileTokenizerTest::long_test(), MBMesquite::QualityAssessor::loop_over_mesh_internal(), main(), FileTokenizerTest::match_multiple_test(), FileTokenizerTest::match_one_test(), FileTokenizerTest::newline_test(), MBMesquite::QuasiNewton::optimize_vertex_positions(), MBMesquite::TrustRegion::optimize_vertex_positions(), MBMesquite::SteepestDescent::optimize_vertex_positions(), MBMesquite::FeasibleNewton::optimize_vertex_positions(), MBMesquite::MeshImpl::read_vtk(), MBMesquite::TerminationCriterion::reset_inner(), XYRectangleTest::setUp(), MBMesquite::DeformingCurveSmoother::store_initial_mesh(), MBMesquite::MeshImpl::tag_to_bool(), MeshInterfaceTest::tearDown(), InstructionQueueTest::test_add_preconditioner(), InstructionQueueTest::test_add_quality_assessor(), InstructionQueueTest::test_add_remove_vertex_slaver(), PatchSetTest::test_bad_handle(), ObjectiveFunctionTests::test_clone(), LinearMappingFunctionTest::test_coeff_fail(), ArrayMeshTest::test_delete_tag(), LinearMappingFunctionTest::test_deriv_fail(), PatchSetTest::test_fail_entities(), PatchSetTest::test_fail_handles(), SlaveBoundaryVerticesTest::test_fail_if_slaves_not_calculated(), InstructionQueueTest::test_insert_preconditioner(), InstructionQueueTest::test_insert_quality_assessor(), InstructionQueueTest::test_remove_preconditioner(), InstructionQueueTest::test_remove_quality_assessor(), ArrayMeshTest::test_tag_data(), iMeshTest::testDoubleTag(), iMeshTest::testIntTag(), FileTokenizerTest::token_test(), uwt(), MBMesquite::MeshImpl::vtk_read_dataset(), and MBMesquite::MeshImpl::write_vtk().

{
    errorCode = NO_ERROR;
    // MS VC6 doesn't have string::clear()!
    errorMessage.resize( 0 );
    stackTrace.clear();
}
bool MBMesquite::MsqError::error ( ) const [inline]

Check if an error has occured.

Definition at line 139 of file MsqError.hpp.

References errorCode, and NO_ERROR.

Referenced by MBMesquite::MsqPrintError::~MsqPrintError().

    {
        return NO_ERROR != errorCode;
    }
const char * MBMesquite::MsqError::error_message ( ) const

Get error message.

Definition at line 45 of file MsqError.cpp.

References errorCode, errorMessage, and LAST_ERROR_CODE.

Referenced by MBMesquite::VertexMover::loop_over_mesh(), and MBMesquite::operator<<().

{
    static const char* const error_messages[] = { "No Error",
                                                  "<unknown>",
                                                  "Out of memory",
                                                  "Invalid argument",
                                                  "Data not initialized",
                                                  "Invalid state",
                                                  "File access error",
                                                  "File format error",
                                                  "Syntax error",
                                                  "I/O error",
                                                  "Invalid mesh",
                                                  "No storage mode for PatchData",
                                                  "Not implemented",
                                                  "Internal error",
                                                  "Interrupted",
                                                  "Duplicate tag name",
                                                  "Tag not found",
                                                  "Unsupported element type",
                                                  "Parallel Error - error occurred on at least one processor",
                                                  "barruer violated when processing barrier Target Metric",
                                                  "Invalid Error Code" };

    /* If this is ever false, it should be caught by a unit test.
       Do an assert here so the unit test fails.
       This asserts that all error codes have a string in the above list. */
    assert( sizeof( error_messages ) == sizeof( char* ) * ( LAST_ERROR_CODE + 1 ) );

    if( !errorMessage.empty() ) return errorMessage.c_str();

    if( errorCode >= 0 && errorCode < LAST_ERROR_CODE ) return error_messages[errorCode];

    return error_messages[LAST_ERROR_CODE];
}
MBMesquite::MsqError::operator bool ( ) const [inline]

Check if an error has occured.

Definition at line 144 of file MsqError.hpp.

References errorCode, and NO_ERROR.

    {
        return NO_ERROR != errorCode;
    }
bool MBMesquite::MsqError::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 125 of file MsqError.cpp.

References stackTrace.

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

{
    stackTrace.push_back( Trace( function, file, line ) );
    return true;
}
static Setter MBMesquite::MsqError::setter ( MsqError err,
const char *  function,
const char *  file,
int  line 
) [inline, static]

Definition at line 226 of file MsqError.hpp.

    {
        return Setter( err, function, file, line );
    }
const StackTrace& MBMesquite::MsqError::stack ( ) const [inline]

Get stack trace.

Definition at line 184 of file MsqError.hpp.

References stackTrace.

Referenced by MBMesquite::operator<<().

    {
        return stackTrace;
    }

Member Data Documentation

std::string MBMesquite::MsqError::errorMessage [private]

Definition at line 233 of file MsqError.hpp.

Referenced by clear(), error_message(), and set_error().

Definition at line 234 of file MsqError.hpp.

Referenced by clear(), push(), set_error(), and stack().

List of all members.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines