summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2014-12-05 14:14:32 +0100
committerAndreas Stöckel <andreas@somweyr.de>2014-12-05 14:14:32 +0100
commitbf59bc2edbb1f3f4d12bfbd8ed2663fbbb1900c0 (patch)
tree30d1fcfaf43045904883f1f068be6347487eedb4 /src/core
parentddbea4164e126739f39658627c04e7e23b71e090 (diff)
removed fatal flag from LoggableException, added constructor capable of using a PosType
Diffstat (limited to 'src/core')
-rw-r--r--src/core/Exceptions.cpp2
-rw-r--r--src/core/Exceptions.hpp45
-rw-r--r--src/core/Logger.hpp29
3 files changed, 27 insertions, 49 deletions
diff --git a/src/core/Exceptions.cpp b/src/core/Exceptions.cpp
index 206f5b2..d064f35 100644
--- a/src/core/Exceptions.cpp
+++ b/src/core/Exceptions.cpp
@@ -26,7 +26,7 @@ namespace ousia {
std::string LoggableException::formatMessage(const std::string &msg,
const std::string &file,
- bool fatal, int line, int column)
+ int line, int column)
{
std::stringstream ss;
ss << "error ";
diff --git a/src/core/Exceptions.hpp b/src/core/Exceptions.hpp
index a5d50d5..00d6106 100644
--- a/src/core/Exceptions.hpp
+++ b/src/core/Exceptions.hpp
@@ -81,8 +81,8 @@ private:
* reported to the runtime environment.
*/
static std::string formatMessage(const std::string &msg,
- const std::string &file, bool fatal,
- int line, int column);
+ const std::string &file, int line,
+ int column);
public:
/**
@@ -96,12 +96,6 @@ public:
const std::string file;
/**
- * If set to true, the exception should not be handled as recoverable error
- * but as "fatal" error.
- */
- const bool fatal;
-
- /**
* Line at which the exception occured. Negative values are ignored.
*/
const int line;
@@ -118,14 +112,12 @@ public:
* @param file provides the context the message refers to. May be empty.
* @param line is the line in the above file the message refers to.
* @param column is the column in the above file the message refers to.
- * @param fatal shoudl be set to true if the error is non-recoverable.
*/
- LoggableException(std::string msg, std::string file, bool fatal,
- int line = -1, int column = -1)
- : OusiaException(formatMessage(msg, file, fatal, line, column)),
+ LoggableException(std::string msg, std::string file, int line = -1,
+ int column = -1)
+ : OusiaException(formatMessage(msg, file, line, column)),
msg(std::move(msg)),
file(std::move(file)),
- fatal(fatal),
line(line),
column(column)
{
@@ -135,49 +127,30 @@ public:
* Constructor of the LoggableException class with empty file.
*
* @param msg contains the error message.
- * @param fatal should be set to true if the error is non-recoverable.
* @param line is the line in the above file the message refers to.
* @param column is the column in the above file the message refers to.
*/
- LoggableException(std::string msg, bool fatal, int line = -1, int column = -1)
- : OusiaException(formatMessage(msg, "", fatal, line, column)),
+ LoggableException(std::string msg, int line = -1, int column = -1)
+ : OusiaException(formatMessage(msg, "", line, column)),
msg(std::move(msg)),
- fatal(fatal),
line(line),
column(column)
{
}
/**
- * Constructor of the LoggableException class with empty file.
- *
- * @param msg contains the error message.
- * @param fatal should be set to true if the error is non-recoverable.
- */
- LoggableException(std::string msg, bool fatal)
- : OusiaException(formatMessage(msg, "", fatal, -1, -1)),
- msg(std::move(msg)),
- fatal(fatal),
- line(-1),
- column(-1)
- {
- }
-
- /**
* Constructor of the LoggableException class with empty file and an
* position object.
*
* @param msg is the actual log message.
* @param pos is a const reference to a variable which provides position
* information.
- * @param fatal should be set to true if the error is non-recoverable.
*/
template <class PosType>
- LoggableException(std::string msg, bool fatal, const PosType &pos)
+ LoggableException(std::string msg, const PosType &pos)
: OusiaException(
- formatMessage(msg, "", fatal, pos.getLine(), pos.getColumn())),
+ formatMessage(msg, "", pos.getLine(), pos.getColumn())),
msg(std::move(msg)),
- fatal(fatal),
line(pos.getLine()),
column(pos.getColumn())
{
diff --git a/src/core/Logger.hpp b/src/core/Logger.hpp
index fd7bb08..e6b97f4 100644
--- a/src/core/Logger.hpp
+++ b/src/core/Logger.hpp
@@ -251,7 +251,7 @@ public:
* @tparam PosType is the actual type of pos and must implement a getLine
* and getColumn function.
*/
- template<class PosType>
+ template <class PosType>
void logAt(Severity severity, const std::string &msg, const PosType &pos)
{
log(severity, msg, pos.getLine(), pos.getColumn());
@@ -264,7 +264,7 @@ public:
*/
void log(const LoggableException &ex)
{
- log(ex.fatal ? Severity::FATAL_ERROR : Severity::ERROR, ex.msg,
+ log(Severity::ERROR, ex.msg,
ex.file.empty() ? currentFilename() : ex.file, ex.line, ex.column);
}
@@ -279,7 +279,8 @@ public:
* @param column is the column in the above file at which the error occured.
* Ignored if negative.
*/
- void debug(const std::string &msg, const std::string &file, int line = -1, int column = -1)
+ void debug(const std::string &msg, const std::string &file, int line = -1,
+ int column = -1)
{
log(Severity::DEBUG, msg, file, line, column);
}
@@ -308,7 +309,7 @@ public:
* @param pos is a const reference to a variable which provides position
* information.
*/
- template<class PosType>
+ template <class PosType>
void debugAt(const std::string &msg, const PosType &pos)
{
debug(msg, pos.getLine(), pos.getColumn());
@@ -325,7 +326,8 @@ public:
* @param column is the column in the above file at which the error occured.
* Ignored if negative.
*/
- void note(const std::string &msg, const std::string &file, int line = -1, int column = -1)
+ void note(const std::string &msg, const std::string &file, int line = -1,
+ int column = -1)
{
log(Severity::NOTE, msg, file, line, column);
}
@@ -353,7 +355,7 @@ public:
* @param pos is a const reference to a variable which provides position
* information.
*/
- template<class PosType>
+ template <class PosType>
void noteAt(const std::string &msg, const PosType &pos)
{
note(msg, pos.getLine(), pos.getColumn());
@@ -370,7 +372,8 @@ public:
* @param column is the column in the above file at which the error occured.
* Ignored if negative.
*/
- void warning(const std::string &msg, const std::string &file, int line = -1, int column = -1)
+ void warning(const std::string &msg, const std::string &file, int line = -1,
+ int column = -1)
{
log(Severity::WARNING, msg, file, line, column);
}
@@ -383,7 +386,7 @@ public:
* @param pos is a const reference to a variable which provides position
* information.
*/
- template<class PosType>
+ template <class PosType>
void warningAt(const std::string &msg, const PosType &pos)
{
warning(msg, pos.getLine(), pos.getColumn());
@@ -415,7 +418,8 @@ public:
* @param column is the column in the above file at which the error occured.
* Ignored if negative.
*/
- void error(const std::string &msg, const std::string &file, int line = -1, int column = -1)
+ void error(const std::string &msg, const std::string &file, int line = -1,
+ int column = -1)
{
log(Severity::ERROR, msg, file, line, column);
}
@@ -443,7 +447,7 @@ public:
* @param pos is a const reference to a variable which provides position
* information.
*/
- template<class PosType>
+ template <class PosType>
void errorAt(const std::string &msg, const PosType &pos)
{
error(msg, pos.getLine(), pos.getColumn());
@@ -460,7 +464,8 @@ public:
* @param column is the column in the above file at which the error occured.
* Ignored if negative.
*/
- void fatalError(const std::string &msg, const std::string &file, int line = -1, int column = -1)
+ void fatalError(const std::string &msg, const std::string &file,
+ int line = -1, int column = -1)
{
log(Severity::FATAL_ERROR, msg, file, line, column);
}
@@ -488,7 +493,7 @@ public:
* @param pos is a const reference to a variable which provides position
* information.
*/
- template<class PosType>
+ template <class PosType>
void fatalErrorAt(const std::string &msg, const PosType &pos)
{
fatalError(msg, pos.getLine(), pos.getColumn());