ALL
0.9.4
A Loadbalacing Library
Toggle main menu visibility
Loading...
Searching...
No Matches
ALL_CustomExceptions.hpp
Go to the documentation of this file.
1
/*
2
Copyright 2018-2020 Rene Halver, Forschungszentrum Juelich GmbH, Germany
3
Copyright 2018-2020 Godehard Sutmann, Forschungszentrum Juelich GmbH, Germany
4
5
Redistribution and use in source and binary forms, with or without modification,
6
are permitted provided that the following conditions are met:
7
8
1. Redistributions of source code must retain the above copyright notice, this
9
list of conditions and the following disclaimer.
10
11
2. Redistributions in binary form must reproduce the above copyright notice,
12
this list of conditions and the following disclaimer in the documentation and/or
13
other materials provided with the distribution.
14
15
3. Neither the name of the copyright holder nor the names of its contributors
16
may be used to endorse or promote products derived from this software without
17
specific prior written permission.
18
19
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
23
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
*/
30
31
#ifndef ALL_CUSTOM_EXCEPTIONS_INC
32
#define ALL_CUSTOM_EXCEPTIONS_INC
33
34
#include <exception>
35
#include <sstream>
36
#include <string>
37
38
namespace
ALL
{
39
41
struct
CustomException
:
public
std::exception {
42
protected
:
44
const
char
*
file
;
46
const
char
*
func
;
48
int
line
;
50
const
char
*
info
;
52
const
char
*
loc_desc
;
54
std::string
error_msg
;
57
enum struct
ErrorID
:
int
{
58
Generic
= 1,
59
PointDimensionMissmatch
,
60
InvalidCommType
,
61
InvalidArgument
,
62
OutOfBounds
,
63
InternalError
,
64
FilesystemError
65
};
66
67
ErrorID
error_id
;
68
69
public
:
76
CustomException
(
const
char
*file_ =
""
,
const
char
*f_ =
""
,
int
l_ = -1,
77
const
char
*i_ =
""
,
78
const
char
*loc_desc_ =
"ALLCustomException"
,
79
const
ErrorID
error_id_ =
ErrorID::Generic
)
80
:
file
(file_),
func
(f_),
line
(l_),
info
(i_),
loc_desc
(loc_desc_),
error_id
(error_id_) {
81
std::stringstream ss;
82
ss <<
loc_desc
<<
": "
<<
info
<<
"\n"
83
<<
"Function: "
<<
func
<<
"\n"
84
<<
"File: "
<<
file
<<
"\n"
85
<<
"Line: "
<<
line
<<
"\n"
;
86
error_msg
= ss.str();
87
}
88
90
const
char
*
get_func
()
const
{
return
func
; }
91
94
int
get_line
()
const
{
return
line
; }
95
99
const
char
*
get_info
() {
return
info
; }
100
103
virtual
const
char
*
what
()
const
throw() {
return
error_msg
.c_str(); }
104
107
int
get_error_id
() {
return
static_cast<
int
>
(
error_id
); }
108
};
109
111
struct
PointDimensionMissmatchException
:
public
CustomException
{
112
public
:
119
PointDimensionMissmatchException
(
120
const
char
*file_,
const
char
*f_,
int
l_,
121
const
char
*i_ =
"Dimension missmatch in Point objects."
,
122
const
char
*loc_desc_ =
"ALLPointDimMissmatchException"
,
123
const
ErrorID
error_id_ =
ErrorID::PointDimensionMissmatch
)
124
:
CustomException
(file_, f_, l_, i_, loc_desc_, error_id_) {}
125
};
126
127
// Execption to be used for invalid Communicators in a load-balancing method
128
struct
InvalidCommTypeException
:
public
CustomException
{
129
public
:
136
InvalidCommTypeException
(
137
const
char
*file_,
const
char
*f_,
int
l_,
138
const
char
*i_ =
"Type of MPI communicator not valid."
,
139
const
char
*loc_desc_ =
"ALLCommTypeInvalidException"
,
140
const
ErrorID
error_id_ =
ErrorID::InvalidCommType
)
141
:
CustomException
(file_, f_, l_, i_, loc_desc_, error_id_) {}
142
};
143
144
// Execption to be used for invalid parameters in any type of classes
145
struct
InvalidArgumentException
:
public
CustomException
{
146
public
:
153
InvalidArgumentException
(
154
const
char
*file_,
const
char
*f_ =
""
,
int
l_ = -1,
155
const
char
*i_ =
"Invalid argument given."
,
156
const
char
*loc_desc_ =
"ALLInvalidArgumentException"
,
157
const
ErrorID
error_id_ =
ErrorID::InvalidArgument
)
158
:
CustomException
(file_, f_, l_, i_, loc_desc_, error_id_) {}
159
};
160
161
// Execption to be used if an array went out of bounds
162
struct
OutOfBoundsException
:
public
CustomException
{
163
public
:
170
OutOfBoundsException
(
171
const
char
*file_,
const
char
*f_ =
""
,
int
l_ = -1,
172
const
char
*i_ =
"Access to array out of bounds."
,
173
const
char
*loc_desc_ =
"ALLOutOfBoundsErrorException"
,
174
const
ErrorID
error_id_ =
ErrorID::OutOfBounds
)
175
:
CustomException
(file_, f_, l_, i_, loc_desc_, error_id_) {}
176
};
177
178
// Execption to be used if an internal error has occured
179
struct
InternalErrorException
:
public
CustomException
{
180
public
:
187
InternalErrorException
(
188
const
char
*file_,
const
char
*f_ =
""
,
int
l_ = -1,
189
const
char
*i_ =
"Internal error occured, see description."
,
190
const
char
*loc_desc_ =
"ALLInternalErrorException"
,
191
const
ErrorID
error_id_ =
ErrorID::InternalError
)
192
:
CustomException
(file_, f_, l_, i_, loc_desc_, error_id_) {}
193
};
194
195
// Execption to be used if a filesystem error has occured
196
struct
FilesystemErrorException
:
public
CustomException
{
197
public
:
204
FilesystemErrorException
(
205
const
char
*file_,
const
char
*f_ =
""
,
int
l_ = -1,
206
const
char
*i_ =
"Filesystem error occured, see description."
,
207
const
char
*loc_desc_ =
"ALLFilesystemErrorException"
,
208
const
ErrorID
error_id_ =
ErrorID::FilesystemError
)
209
:
CustomException
(file_, f_, l_, i_, loc_desc_, error_id_) {}
210
};
211
212
}
//namespace ALL
213
214
#endif
ALL
Definition
ALL.hpp:78
ALL::CustomException::error_id
ErrorID error_id
error identificator retrieved by Fortran
Definition
ALL_CustomExceptions.hpp:67
ALL::CustomException::get_line
int get_line() const
Definition
ALL_CustomExceptions.hpp:94
ALL::CustomException::loc_desc
const char * loc_desc
name of the exception
Definition
ALL_CustomExceptions.hpp:52
ALL::CustomException::ErrorID
ErrorID
Definition
ALL_CustomExceptions.hpp:57
ALL::CustomException::ErrorID::PointDimensionMissmatch
@ PointDimensionMissmatch
Definition
ALL_CustomExceptions.hpp:59
ALL::CustomException::ErrorID::InvalidArgument
@ InvalidArgument
Definition
ALL_CustomExceptions.hpp:61
ALL::CustomException::ErrorID::OutOfBounds
@ OutOfBounds
Definition
ALL_CustomExceptions.hpp:62
ALL::CustomException::ErrorID::FilesystemError
@ FilesystemError
Definition
ALL_CustomExceptions.hpp:64
ALL::CustomException::ErrorID::Generic
@ Generic
Definition
ALL_CustomExceptions.hpp:58
ALL::CustomException::ErrorID::InternalError
@ InternalError
Definition
ALL_CustomExceptions.hpp:63
ALL::CustomException::ErrorID::InvalidCommType
@ InvalidCommType
Definition
ALL_CustomExceptions.hpp:60
ALL::CustomException::info
const char * info
information on the exception
Definition
ALL_CustomExceptions.hpp:50
ALL::CustomException::CustomException
CustomException(const char *file_="", const char *f_="", int l_=-1, const char *i_="", const char *loc_desc_="ALLCustomException", const ErrorID error_id_=ErrorID::Generic)
Definition
ALL_CustomExceptions.hpp:76
ALL::CustomException::what
virtual const char * what() const
Definition
ALL_CustomExceptions.hpp:103
ALL::CustomException::error_msg
std::string error_msg
error message
Definition
ALL_CustomExceptions.hpp:54
ALL::CustomException::file
const char * file
file the exception occured in
Definition
ALL_CustomExceptions.hpp:44
ALL::CustomException::func
const char * func
function the exception occured in
Definition
ALL_CustomExceptions.hpp:46
ALL::CustomException::get_func
const char * get_func() const
Definition
ALL_CustomExceptions.hpp:90
ALL::CustomException::get_info
const char * get_info()
Definition
ALL_CustomExceptions.hpp:99
ALL::CustomException::get_error_id
int get_error_id()
Definition
ALL_CustomExceptions.hpp:107
ALL::CustomException::line
int line
line the exception occured in
Definition
ALL_CustomExceptions.hpp:48
ALL::FilesystemErrorException::FilesystemErrorException
FilesystemErrorException(const char *file_, const char *f_="", int l_=-1, const char *i_="Filesystem error occured, see description.", const char *loc_desc_="ALLFilesystemErrorException", const ErrorID error_id_=ErrorID::FilesystemError)
Definition
ALL_CustomExceptions.hpp:204
ALL::InternalErrorException::InternalErrorException
InternalErrorException(const char *file_, const char *f_="", int l_=-1, const char *i_="Internal error occured, see description.", const char *loc_desc_="ALLInternalErrorException", const ErrorID error_id_=ErrorID::InternalError)
Definition
ALL_CustomExceptions.hpp:187
ALL::InvalidArgumentException::InvalidArgumentException
InvalidArgumentException(const char *file_, const char *f_="", int l_=-1, const char *i_="Invalid argument given.", const char *loc_desc_="ALLInvalidArgumentException", const ErrorID error_id_=ErrorID::InvalidArgument)
Definition
ALL_CustomExceptions.hpp:153
ALL::InvalidCommTypeException::InvalidCommTypeException
InvalidCommTypeException(const char *file_, const char *f_, int l_, const char *i_="Type of MPI communicator not valid.", const char *loc_desc_="ALLCommTypeInvalidException", const ErrorID error_id_=ErrorID::InvalidCommType)
Definition
ALL_CustomExceptions.hpp:136
ALL::OutOfBoundsException::OutOfBoundsException
OutOfBoundsException(const char *file_, const char *f_="", int l_=-1, const char *i_="Access to array out of bounds.", const char *loc_desc_="ALLOutOfBoundsErrorException", const ErrorID error_id_=ErrorID::OutOfBounds)
Definition
ALL_CustomExceptions.hpp:170
ALL::PointDimensionMissmatchException::PointDimensionMissmatchException
PointDimensionMissmatchException(const char *file_, const char *f_, int l_, const char *i_="Dimension missmatch in Point objects.", const char *loc_desc_="ALLPointDimMissmatchException", const ErrorID error_id_=ErrorID::PointDimensionMissmatch)
Definition
ALL_CustomExceptions.hpp:119
include
ALL_CustomExceptions.hpp
Generated by
1.17.0