]> git.tdb.fi Git - libs/core.git/blobdiff - source/core/except.h
Don't throw on win32 if file has no owner or group
[libs/core.git] / source / core / except.h
index fc6fcc6c69921f48205fea5434a9b8da5cb05671..ed295f11cef6c50d7fb1c407a7c89852e2d8b2b6 100644 (file)
@@ -1,16 +1,9 @@
-/* $Id$
-
-This file is part of libmspcore
-Copyright © 2006-2008  Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
 #ifndef MSP_CORE_ERROR_H_
 #define MSP_CORE_ERROR_H_
 
 #include <exception>
 #include <string>
-#include "../debug/backtrace.h"
+#include <msp/debug/backtrace.h>
 
 namespace Msp {
 
@@ -19,6 +12,11 @@ Base class for all Msp exceptions.
 */
 class Exception: public std::exception
 {
+private:
+       std::string wot;
+       std::string wer;
+       Debug::Backtrace bt;
+
 public:
        Exception(const std::string &);
        ~Exception() throw() { }
@@ -27,11 +25,6 @@ public:
        Exception &at(const std::string &) throw();
        const char *where() const throw() { return wer.c_str(); }
        const Debug::Backtrace &get_backtrace() const throw() { return bt; }
-private:
-       std::string wot;
-       std::string wer;
-       Debug::Backtrace bt;
-
 };
 
 /**
@@ -48,13 +41,15 @@ Thrown when a lookup from a map fails.
 */
 class KeyError: public Exception
 {
+private:
+       std::string key;
+
 public:
        KeyError(const std::string &w_): Exception(w_) { }
        KeyError(const std::string &w_, const std::string &k);
-       const std::string &get_key() const { return key; }
        ~KeyError() throw() { }
-private:
-       std::string key;
+
+       const std::string &get_key() const { return key; }
 };
 
 /**
@@ -71,11 +66,12 @@ Thrown when the application is invoked with wrong parameters.
 */
 class UsageError: public Exception
 {
-public:
-       UsageError(const std::string &r, bool b=true): Exception(r), brief(b) { }
-       bool get_brief() const { return brief; }
 private:
        bool brief;
+
+public:
+       UsageError(const std::string &r, bool b = true): Exception(r), brief(b) { }
+       bool get_brief() const { return brief; }
 };
 
 /**
@@ -83,15 +79,26 @@ Thrown when a system call fails.
 */
 class SystemError: public Exception
 {
+private:
+       int err;
+
 public:
        SystemError(const std::string &, int);
        int get_error_code() const { return err; }
-private:
-       int err;
 
+private:
        static std::string build_what(const std::string &, int);
 };
 
+/**
+Thrown when "impossible" things happen.
+*/
+class LogicError: public Exception
+{
+public:
+       LogicError(const std::string &w_): Exception(w_) { }
+};
+
 template<typename E>
 void throw_at(E e, const std::string &a)
 { e.at(a); throw e; }