summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0813571)
raw | patch | inline | side by side (parent: 0813571)
author | johanengelen <johanengelen@users.sourceforge.net> | |
Sat, 17 Nov 2007 01:44:59 +0000 (01:44 +0000) | ||
committer | johanengelen <johanengelen@users.sourceforge.net> | |
Sat, 17 Nov 2007 01:44:59 +0000 (01:44 +0000) |
index 0d84ee7f33ed3ce8a5ca8124bba015b3d5264ba5..ee1244a7390da29b41830a3001b4a8b6ae2011cc 100644 (file)
std::vector<std::pair<double, double> >
find_self_intersections(OldBezier const &Sb) {
- throw NotImplemented();
+ throwNotImplemented();
}
std::vector<std::pair<double, double> >
diff --git a/src/2geom/path.cpp b/src/2geom/path.cpp
index 98fec6e24555c3cd9f2fc632c7a9b13984ba7a54..ba6643ae4af9a29b0c950aa223ee5b93a200f775 100644 (file)
--- a/src/2geom/path.cpp
+++ b/src/2geom/path.cpp
}
Rect SVGEllipticalArc::boundsFast() const {
- throw NotImplemented();
+ throwNotImplemented();
}
Rect SVGEllipticalArc::boundsExact() const {
- throw NotImplemented();
+ throwNotImplemented();
}
Rect SVGEllipticalArc::boundsLocal(Interval i, unsigned deg) const {
- //throw NotImplemented();
+ throwNotImplemented();
}
std::vector<Point> SVGEllipticalArc::pointAndDerivatives(Coord t, unsigned n) const {
- throw NotImplemented();
+ throwNotImplemented();
}
std::vector<double> SVGEllipticalArc::roots(double v, Dim2 d) const {
- //throw NotImplemented();
+ throwNotImplemented();
}
D2<SBasis> SVGEllipticalArc::toSBasis() const {
diff --git a/src/2geom/path.h b/src/2geom/path.h
index 46d7f230aa87e02a36a090596c4fb04e1aeaf777..053bc06c960fb9da48f495e0c2bce7ea4490c1c1 100644 (file)
--- a/src/2geom/path.h
+++ b/src/2geom/path.h
#include "matrix.h"
#include "bezier.h"
#include "crossing.h"
+#include "utils.h"
namespace Geom {
return ret;
}
- Curve *derivative() const { throw NotImplemented(); }
+ Curve *derivative() const { throwNotImplemented(); }
std::vector<Point> pointAndDerivatives(Coord t, unsigned n) const;
Rect boundsFast() const { return actualPath().boundsFast; }
Rect boundsExact() const { return actualPath().boundsFast; }
- Rect boundsLocal(Interval i) const { throw NotImplemented(); }
+ Rect boundsLocal(Interval i) const { throwNotImplemented(); }
std::vector<double> roots(double v, Dim2 d) const = 0;
diff --git a/src/2geom/piecewise.h b/src/2geom/piecewise.h
index b4f000dc4ef307864607f9376e4b09a83c7d4054..c70ecd42cb69be42e8bfd2e4ef846dc190e0ea81 100644 (file)
--- a/src/2geom/piecewise.h
+++ b/src/2geom/piecewise.h
}\r
//Convenience/implementation hiding function to add cuts.\r
inline void push_cut(double c) {\r
- assert(cuts.empty() || c > cuts.back()); \r
+ assert_invariants(cuts.empty() || c > cuts.back()); \r
cuts.push_back(c);\r
}\r
//Convenience/implementation hiding function to add segments.\r
diff --git a/src/2geom/sbasis.h b/src/2geom/sbasis.h
index 9fc16f1c6caa639da53cebeda6fd750ec245beb9..df41dca584fd8d1da82ebf5c73eb044620c3d049 100644 (file)
--- a/src/2geom/sbasis.h
+++ b/src/2geom/sbasis.h
std::vector<double> valueAndDerivatives(double /*t*/, unsigned /*n*/) const {
//TODO
- throw NotImplemented();
+ throwNotImplemented();
+ //throw(NotImplemented(__FILE__, __LINE__));
}
SBasis toSBasis() const { return SBasis(*this); }
diff --git a/src/2geom/shape.cpp b/src/2geom/shape.cpp
index 3cf6d0bc0ddab00c1e03737bcd886b2bbb7d4462..70a7d088421fa86197808eac8e1a58d4c58304dc 100644 (file)
--- a/src/2geom/shape.cpp
+++ b/src/2geom/shape.cpp
@@ -191,7 +191,7 @@ Shape shape_boolean_rb(bool rev, Shape const &a, Shape const &b, CrossingSet con
* NOTE: currently doesn't work, as the CrossingSet reversal functions crash
*/
Shape boolop(Shape const &a, Shape const &b, unsigned flags, CrossingSet const &crs) {
- throw NotImplemented();
+ throwNotImplemented();
flags &= 15;
if(flags <= BOOLOP_UNION) {
switch(flags) {
diff --git a/src/2geom/utils.h b/src/2geom/utils.h
index 50dfa82fe5ac68c0c5a54ca6b16d4eeb24588028..cd2a9c26ce3c0c3e003ccbe61b9974b792565fea 100644 (file)
--- a/src/2geom/utils.h
+++ b/src/2geom/utils.h
/** Various utility functions.
*
+ * Copyright 2007 Johan Engelen <goejendaagh@zonnet.nl>
* Copyright 2006 Michael G. Sloan <mgsloan@gmail.com>
*
* This library is free software; you can redistribute it and/or
namespace Geom {
-class NotImplemented : public std::logic_error {
+
+//#######################################################################
+// Base exception class, all 2geom exceptions should be derrived from this one.
+class Exception : public std::exception {
+public:
+ Exception(const char * message, const char *file, const int line) {
+ msgstr = "Exception thrown: ";
+ msgstr += message;
+ msgstr += " (";
+ msgstr += file;
+ msgstr += ":";
+ msgstr += line;
+ msgstr += ")";
+ };
+ virtual ~Exception() throw() {}; // necessary to destroy the string object!!!
+ virtual const char * what() const throw () { return msgstr.c_str(); }
+protected:
+ std::string msgstr;
+};
+
+//-----------------------------------------------------------------------
+// Two main exception classes: LogicalError and RangeError.
+// Logical errors are 2geom faults/bugs, RangeErrors are 'user' faults.
+// This way, the 'user' can distinguish between groups of exceptions
+// ('user' is the coder that uses lib2geom)
+class LogicalError : public Exception {
+public:
+ LogicalError(const char * message, const char *file, const int line)
+ : Exception(message, file, line) {};
+};
+#define throwLogicalError(message) throw(LogicalError(message, __FILE__, __LINE__))
+
+class RangeError : public Exception {
+public:
+ RangeError(const char * message, const char *file, const int line)
+ : Exception(message, file, line) {};
+};
+#define throwRangeError(message) throw(RangeError(message, __FILE__, __LINE__))
+
+//-----------------------------------------------------------------------
+// Special case exceptions. Best used with the defines :)
+
+class NotImplemented : public LogicalError {
+public:
+ NotImplemented(const char *file, const int line)
+ : LogicalError("Method not implemented", file, line) {};
+};
+#define throwNotImplemented(i) throw(NotImplemented(__FILE__, __LINE__))
+
+class InvariantsViolation : public LogicalError {
public:
- NotImplemented() : std::logic_error("method not implemented") {}
+ InvariantsViolation(const char *file, const int line)
+ : LogicalError("Invariants violation", file, line) {};
};
+#define throwInvariantsViolation(i) throw(InvariantsViolation(__FILE__, __LINE__))
+#define assert_invariants(e) ((e) ? (void)0 : throwInvariantsViolation())
-class NotInvertible : public std::range_error {
- public:
- NotInvertible() : std::range_error("function does not have a unique inverse") {}
+class NotInvertible : public RangeError {
+public:
+ NotInvertible(const char *file, const int line)
+ : RangeError("Function does not have a unique inverse", file, line) {};
};
+#define throwNotInvertible(i) throw(NotInvertible(__FILE__, __LINE__))
+
+//#######################################################################
// proper logical xor
inline bool logical_xor (bool a, bool b) { return (a || b) && !(a && b); }
index f87e365bc337416847b58d1b3313e4cd1e8aedc8..4ccfa59524720c04365036bf6ca89a44e4f55726 100644 (file)
return new_bpath;
}
catch (std::exception e) {
- g_warning("An exception occurred during execution of an LPE - %s", e.what());
+ g_warning("Exception during LPE %s execution. \n %s", getName().c_str(), e.what());
SP_ACTIVE_DESKTOP->messageStack()->flash( Inkscape::WARNING_MESSAGE,
- _("An exception occurred during execution of a Path Effect.") );
+ _("An exception occurred during execution of the Path Effect.") );
NArtBpath *path_out;