Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbubnikv <bubnikv@gmail.com>2018-04-06 17:49:33 +0300
committerbubnikv <bubnikv@gmail.com>2018-04-06 17:49:33 +0300
commit670061ac333cf96007b3c599fc8981bd7f2150a6 (patch)
tree76285989b8cb3cc92ac8d2bfaca1ec4a3e4ac0e6 /xs/src/libslic3r/FileParserError.hpp
parent2b8da333efa035966afb54a120b0e9d795c219dc (diff)
Initial implementation of configuration snapshotting.
Diffstat (limited to 'xs/src/libslic3r/FileParserError.hpp')
-rw-r--r--xs/src/libslic3r/FileParserError.hpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/xs/src/libslic3r/FileParserError.hpp b/xs/src/libslic3r/FileParserError.hpp
new file mode 100644
index 000000000..82a6b328e
--- /dev/null
+++ b/xs/src/libslic3r/FileParserError.hpp
@@ -0,0 +1,48 @@
+#ifndef slic3r_FileParserError_hpp_
+#define slic3r_FileParserError_hpp_
+
+#include "libslic3r.h"
+
+#include <string>
+#include <stdexcept>
+
+namespace Slic3r {
+
+// Generic file parser error, mostly copied from boost::property_tree::file_parser_error
+class file_parser_error: public std::runtime_error
+{
+public:
+ file_parser_error(const std::string &msg, const std::string &file, unsigned long line = 0) :
+ std::runtime_error(format_what(msg, file, line)),
+ m_message(msg), m_filename(file), m_line(line) {}
+ // gcc 3.4.2 complains about lack of throw specifier on compiler
+ // generated dtor
+ ~file_parser_error() throw() {}
+
+ // Get error message (without line and file - use what() to get full message)
+ std::string message() const { return m_message; }
+ // Get error filename
+ std::string filename() const { return m_filename; }
+ // Get error line number
+ unsigned long line() const { return m_line; }
+
+private:
+ std::string m_message;
+ std::string m_filename;
+ unsigned long m_line;
+
+ // Format error message to be returned by std::runtime_error::what()
+ static std::string format_what(const std::string &msg, const std::string &file, unsigned long l)
+ {
+ std::stringstream stream;
+ stream << (file.empty() ? "<unspecified file>" : file.c_str());
+ if (l > 0)
+ stream << '(' << l << ')';
+ stream << ": " << msg;
+ return stream.str();
+ }
+};
+
+}; // Slic3r
+
+#endif // slic3r_FileParserError_hpp_