Skip to content
Snippets Groups Projects

Feature/amalgamated

3 files
+ 42
13
Compare changes
  • Side-by-side
  • Inline

Files

+ 34
12
@@ -52,6 +52,18 @@ protected:
const char *loc_desc;
/// error message
std::string error_msg;
/// error identificators for Fortran error retrieval, remember to
/// update the Fortran module as well!
enum struct ErrorID : int {
Generic = 1,
PointDimensionMissmatch,
InvalidCommType,
InvalidArgument,
OutOfBounds,
InternalError
};
/// error identificator retrieved by Fortran
ErrorID error_id;
public:
/// constructor for an exception used in ALL
@@ -62,8 +74,9 @@ public:
/// @param loc_desc internal description of the exception type
CustomException(const char *file_ = "", const char *f_ = "", int l_ = -1,
const char *i_ = "",
const char *loc_desc_ = "ALLCustomException")
: file(file_), func(f_), line(l_), info(i_), loc_desc(loc_desc_) {
const char *loc_desc_ = "ALLCustomException",
const ErrorID error_id_ = ErrorID::Generic)
: file(file_), func(f_), line(l_), info(i_), loc_desc(loc_desc_), error_id(error_id_) {
std::stringstream ss;
ss << loc_desc << ": " << info << "\n"
<< "Function: " << func << "\n"
@@ -87,6 +100,10 @@ public:
/// overloaded method from the base Exception class to return an error message
/// @return the error message of the exception
virtual const char *what() const throw() { return error_msg.c_str(); }
/// retrieve error id for Fortran interface
/// @return error id from ErrorID enum
int get_error_id() { return static_cast<int>(error_id); }
};
/// Exception to be used for missmatches in dimension for ALL::Point class
@@ -101,8 +118,9 @@ public:
PointDimensionMissmatchException(
const char *file_, const char *f_, int l_,
const char *i_ = "Dimension missmatch in Point objects.",
const char *loc_desc_ = "ALLPointDimMissmatchException")
: CustomException(file_, f_, l_, i_, loc_desc_) {}
const char *loc_desc_ = "ALLPointDimMissmatchException",
const ErrorID error_id_ = ErrorID::PointDimensionMissmatch)
: CustomException(file_, f_, l_, i_, loc_desc_, error_id_) {}
};
// Execption to be used for invalid Communicators in a load-balancing method
@@ -117,8 +135,9 @@ public:
InvalidCommTypeException(
const char *file_, const char *f_, int l_,
const char *i_ = "Type of MPI communicator not valid.",
const char *loc_desc_ = "ALLCommTypeInvalidException")
: CustomException(file_, f_, l_, i_, loc_desc_) {}
const char *loc_desc_ = "ALLCommTypeInvalidException",
const ErrorID error_id_ = ErrorID::InvalidCommType)
: CustomException(file_, f_, l_, i_, loc_desc_, error_id_) {}
};
// Execption to be used for invalid parameters in any type of classes
@@ -133,8 +152,9 @@ public:
InvalidArgumentException(
const char *file_, const char *f_ = "", int l_ = -1,
const char *i_ = "Invalid argument given.",
const char *loc_desc_ = "ALLInvalidArgumentException")
: CustomException(file_, f_, l_, i_, loc_desc_) {}
const char *loc_desc_ = "ALLInvalidArgumentException",
const ErrorID error_id_ = ErrorID::InvalidArgument)
: CustomException(file_, f_, l_, i_, loc_desc_, error_id_) {}
};
// Execption to be used if an array went out of bounds
@@ -149,8 +169,9 @@ public:
OutOfBoundsException(
const char *file_, const char *f_ = "", int l_ = -1,
const char *i_ = "Access to array out of bounds.",
const char *loc_desc_ = "ALLOutOfBoundsErrorException")
: CustomException(file_, f_, l_, i_, loc_desc_) {}
const char *loc_desc_ = "ALLOutOfBoundsErrorException",
const ErrorID error_id_ = ErrorID::OutOfBounds)
: CustomException(file_, f_, l_, i_, loc_desc_, error_id_) {}
};
// Execption to be used if an internal error has occured
@@ -165,8 +186,9 @@ public:
InternalErrorException(
const char *file_, const char *f_ = "", int l_ = -1,
const char *i_ = "Internal error occured, see description.",
const char *loc_desc_ = "ALLInternalErrorException")
: CustomException(file_, f_, l_, i_, loc_desc_) {}
const char *loc_desc_ = "ALLInternalErrorException",
const ErrorID error_id_ = ErrorID::InternalError)
: CustomException(file_, f_, l_, i_, loc_desc_, error_id_) {}
};
}//namespace ALL
Loading