24 #ifndef STORAGE_EXCEPTION_H 25 #define STORAGE_EXCEPTION_H 37 #include "storage/Utils/Logger.h" 55 const std::string & func_r,
57 : _file(file_r), _func(func_r), _line(line_r)
64 : _file(), _func(), _line(0)
70 const std::string&
file()
const {
return _file; }
75 const std::string&
func()
const {
return _func; }
80 int line()
const {
return _line; }
126 Exception(
const std::string & msg, LogLevel log_level = ERROR);
143 { _where = newLocation; }
150 const std::string &
msg()
const 156 LogLevel log_level()
const {
return _log_level; }
172 static std::string strErrno(
int errno_r );
177 static std::string strErrno(
int errno_r,
const std::string & msg );
183 static void log(
const Exception & exception,
185 const char *
const prefix );
192 virtual const char *
what() const noexcept
193 {
return _msg.c_str(); }
200 virtual std::ostream & dumpOn( std::ostream & str )
const;
204 friend std::ostream &
operator<<( std::ostream & str,
216 std::ostream & dumpError( std::ostream & str )
const;
301 const std::string & msg =
"" )
303 , _invalidIndex( invalidIndex )
304 , _validMin( validMin )
305 , _validMax( validMax )
332 virtual std::ostream &
dumpOn( std::ostream & str )
const 334 std::string prefix = msg();
336 if ( prefix.empty() )
337 prefix =
"Index out of range";
339 return str << prefix <<
": " << _invalidIndex
340 <<
" valid: " << _validMin <<
" .. " << _validMax
381 const std::string & seen,
382 const std::string & expected ):
385 _expected( expected )
397 const std::string &
seen()
const {
return _seen; }
402 const std::string &
expected()
const {
return _expected; }
408 virtual std::ostream &
dumpOn( std::ostream & str )
const 410 std::string prefix =
"Parse error";
412 if ( ! msg().empty() )
415 return str << prefix << msg()
416 <<
"; expected: \"" << _expected
417 <<
"\" seen: \"" << _seen <<
"\"" 424 std::string _expected;
Exception class for features not implemented.
Definition: Exception.h:247
CodeLocation()
Default constructor.
Definition: Exception.h:63
Exception class for "index out of range".
Definition: Exception.h:287
Exception class for "overflow".
Definition: Exception.h:355
int validMax() const
Return the valid maximum index.
Definition: Exception.h:324
const std::string & msg() const
Return the message string provided to the constructor.
Definition: Exception.h:150
const std::string & seen() const
The offending line that caused the parse error.
Definition: Exception.h:397
Exception class for "out of memory".
Definition: Exception.h:271
virtual std::ostream & dumpOn(std::ostream &str) const
Write proper error message with all relevant data.
Definition: Exception.h:408
Exception class for faulty logic within the program.
Definition: Exception.h:259
std::string asString() const
Returns the location in normalized string format.
friend std::ostream & operator<<(std::ostream &str, const CodeLocation &obj)
Stream output.
Helper class for UI exceptions: Store BASE_FILE, FUNCTION and LINE.
Definition: Exception.h:47
ParseException(const std::string &msg, const std::string &seen, const std::string &expected)
Constructor.
Definition: Exception.h:380
Exception class for parse errors, e.g.
Definition: Exception.h:369
virtual const char * what() const noexcept
Return message string.
Definition: Exception.h:192
const std::string & func() const
Returns the name of the function where the exception occured.
Definition: Exception.h:75
const CodeLocation & where() const
Return CodeLocation.
Definition: Exception.h:136
void setMsg(const std::string &msg)
Set a new message string.
Definition: Exception.h:161
int validMin() const
Return the valid minimum index.
Definition: Exception.h:319
Exception class for generic null pointer exceptions.
Definition: Exception.h:231
IndexOutOfRangeException(int invalidIndex, int validMin, int validMax, const std::string &msg="")
Constructor.
Definition: Exception.h:298
Base class for storage exceptions.
Definition: Exception.h:113
int line() const
Returns the source line number where the exception occured.
Definition: Exception.h:80
The storage namespace.
Definition: Actiongraph.h:36
void relocate(const CodeLocation &newLocation) const
Exchange location on rethrow.
Definition: Exception.h:142
virtual std::ostream & dumpOn(std::ostream &str) const
Write proper error message with all relevant data.
Definition: Exception.h:332
const std::string & file() const
Returns the source file name where the exception occured.
Definition: Exception.h:70
virtual ~ParseException() noexcept
Destructor.
Definition: Exception.h:391
int invalidIndex() const
Return the offending index value.
Definition: Exception.h:314
const std::string & expected() const
Short textual description of what the parser expected.
Definition: Exception.h:402
CodeLocation(const std::string &file_r, const std::string &func_r, int line_r)
Constructor.
Definition: Exception.h:54