--- /dev/null
+#ifndef SCD_EXCEPTION_H
+#define SCD_EXCEPTION_H
+
+#include <string>
+#include <exception>
+#include <execinfo.h>
+
+
+/**
+ * Maximum level of stacktrace.
+ */
+const int SCD_EX_TRACES = 15;
+
+
+/**
+ * General exeption. Can give a stack trace and generates error messages
+ * from error numbers.
+ */
+class scd_exception : public std::exception
+{
+public:
+ /**
+ * Constructor to create an exception with a string as cause.
+ * \param the cause
+ */
+ scd_exception(const std::string& msg);
+
+ /**
+ * Constroctor to create an exception with a string and an error
+ * message generated from an error number (errno) as cause.
+ * \param the cause prefix
+ * \param the error number to generate the error message for
+ */
+ scd_exception(const std::string& msg, int errn);
+
+ virtual ~scd_exception() throw() {}
+
+ /**
+ * Returns a C-String showing the cause of the exception.
+ */
+ virtual const char* what() throw();
+
+ /**
+ * Returns a C-String showing the stack trace. For name resolution
+ * -rdynamic has to be used while compiling.
+ */
+ const char* stacktrace();
+
+private:
+ std::string _msg;
+ std::string _backtrace;
+
+ void _get_backtrace();
+
+};
+
+#endif