MOAB: Mesh Oriented datABase
(version 5.4.1)
|
Used to hold the error state and return it to the application. More...
#include <MsqError.hpp>
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< Trace > | StackTrace |
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 StackTrace & | stack () 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 |
Used to hold the error state and return it to the application.
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.
typedef std::list< Trace > MBMesquite::MsqError::StackTrace |
Container type used to store stack trace. Return type for stack()
Definition at line 181 of file MsqError.hpp.
Error codes.
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 };
MESQUITE_EXPORT MBMesquite::MsqError::MsqError | ( | ) | [inline] |
Initialize to cleared state.
Definition at line 150 of file MsqError.hpp.
MBMesquite::MsqError::~MsqError | ( | ) | [virtual] |
Destructor - empty but must declar virtual destrucor if virtual functions.
Definition at line 81 of file MsqError.cpp.
{}
void MBMesquite::MsqError::clear | ( | ) |
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().
ErrorCode MBMesquite::MsqError::error_code | ( | ) | const [inline] |
Get error code.
Definition at line 160 of file MsqError.hpp.
References errorCode.
Referenced by MBMesquite::NonGradient::evaluate(), MBMesquite::ConjugateGradient::get_step(), MBMesquite::QualityAssessor::get_tag(), MBMesquite::TargetWriter::get_tag_handle(), MBMesquite::TagVertexMesh::initialize(), MBMesquite::QualityAssessor::loop_over_mesh_internal(), main(), MBMesquite::operator<<(), MBMesquite::QuasiNewton::optimize_vertex_positions(), MBMesquite::TrustRegion::optimize_vertex_positions(), MBMesquite::SteepestDescent::optimize_vertex_positions(), MBMesquite::FeasibleNewton::optimize_vertex_positions(), MBMesquite::DeformingCurveSmoother::store_initial_mesh(), ArrayMeshTest::test_delete_tag(), MeshUtilTest::test_edge_length_distribution_empty(), CompositeOFTest::test_eval_fails(), MeshUtilTest::test_lambda_distribution_empty(), ArrayMeshTest::test_tag_data(), QualityMetricTester::test_type_is_not_supported(), iMeshTest::testDoubleTag(), iMeshTest::testIntTag(), and MBMesquite::MeshImpl::write_vtk().
{ return 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] |
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; }
bool MBMesquite::MsqError::set_error | ( | ErrorCode | num, |
const char * | msg = 0 |
||
) | [virtual] |
Initialize the error object with the passed data.
Definition at line 131 of file MsqError.cpp.
References errorCode, errorMessage, NO_ERROR, and stackTrace.
Referenced by MBMesquite::MsqMOAB::check_valid_flag_tag(), MBMesquite::MsqMOAB::elements_get_attached_vertices(), MBMesquite::MsqMOAB::elements_get_topologies(), MBMesquite::MsqMOAB::get_adjacent_entities(), MBMesquite::MsqMOAB::get_all_elements(), MBMesquite::MsqMOAB::get_flag_data(), MBMesquite::MsqMOAB::init_active_mesh(), MBMesquite::MsqError::Setter::set(), MBMesquite::MsqMOAB::tag_create(), MBMesquite::MsqMOAB::tag_delete(), MBMesquite::MsqMOAB::tag_get(), MBMesquite::MsqMOAB::tag_get_data(), MBMesquite::MsqMOAB::tag_properties(), MBMesquite::MsqMOAB::tag_set_data(), MBMesquite::MsqMOAB::vertex_get_byte(), MBMesquite::MsqMOAB::vertex_set_byte(), MBMesquite::MsqMOAB::vertex_set_coordinates(), MBMesquite::MsqMOAB::vertices_get_byte(), MBMesquite::MsqMOAB::vertices_get_coordinates(), and MBMesquite::MsqMOAB::vertices_set_byte().
{ errorCode = num; stackTrace.clear(); if( msg ) errorMessage = msg; else // MS VC6 doesn't have string::clear()! errorMessage.resize( 0 ); return num != NO_ERROR; }
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; }
ErrorCode MBMesquite::MsqError::errorCode [private] |
Definition at line 232 of file MsqError.hpp.
Referenced by clear(), error(), error_code(), error_message(), operator bool(), and set_error().
std::string MBMesquite::MsqError::errorMessage [private] |
Definition at line 233 of file MsqError.hpp.
Referenced by clear(), error_message(), and set_error().
StackTrace MBMesquite::MsqError::stackTrace [private] |
Definition at line 234 of file MsqError.hpp.
Referenced by clear(), push(), set_error(), and stack().