From aaaf493e3cddcc2cb0797ca3fe7eca4f12a04453 Mon Sep 17 00:00:00 2001 From: Andreas Stöckel Date: Sun, 23 Nov 2014 01:39:42 +0100 Subject: imlemented Logger, TerminalLogger, OusiaException, LoggableException --- src/core/Exceptions.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/core/Exceptions.cpp (limited to 'src/core/Exceptions.cpp') diff --git a/src/core/Exceptions.cpp b/src/core/Exceptions.cpp new file mode 100644 index 0000000..92d9293 --- /dev/null +++ b/src/core/Exceptions.cpp @@ -0,0 +1,45 @@ +/* + Ousía + Copyright (C) 2014, 2015 Benjamin Paaßen, Andreas Stöckel + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include + +#include "Exceptions.hpp" + +namespace ousia { + +/* Class LoggableException */ + +std::string LoggableException::formatMessage(const std::string &msg, + const std::string &file, int line, + int column, bool fatal) +{ + std::stringstream ss; + if (!file.empty()) { + ss << "while processing \"" << file << "\" "; + } + if (line >= 0) { + ss << "at line: " << line << " "; + if (column >= 0) { + ss << "col: " << column << " "; + } + } + ss << "message: " << msg; + return ss.str(); +} +} + -- cgit v1.2.3