summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2016-10-23 17:37:07 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2016-10-23 17:37:07 +0100
commit65446fad1ec69e5d72b28e5c6b4369c0bc8d6537 (patch)
treec7173564a51d0f6ed0effc30881422288d645493
parentAllow working with local types (except classes, need ice_id functionality) (diff)
downloadslicer-65446fad1ec69e5d72b28e5c6b4369c0bc8d6537.tar.bz2
slicer-65446fad1ec69e5d72b28e5c6b4369c0bc8d6537.tar.xz
slicer-65446fad1ec69e5d72b28e5c6b4369c0bc8d6537.zip
Add exception messages to all exceptionsslicer-1.4.1
-rw-r--r--slicer/db/sqlCommon.cpp27
-rw-r--r--slicer/db/sqlExceptions.ice4
-rw-r--r--slicer/slicer/common.ice11
-rw-r--r--slicer/slicer/slicer.cpp74
-rw-r--r--slicer/xml/serializer.cpp7
-rw-r--r--slicer/xml/xmlExceptions.ice1
6 files changed, 124 insertions, 0 deletions
diff --git a/slicer/db/sqlCommon.cpp b/slicer/db/sqlCommon.cpp
new file mode 100644
index 0000000..645c10f
--- /dev/null
+++ b/slicer/db/sqlCommon.cpp
@@ -0,0 +1,27 @@
+#include <sqlExceptions.h>
+#include <boost/format.hpp>
+
+namespace Slicer {
+ void TooManyRowsReturned::ice_print(std::ostream & s) const
+ {
+ s << "Too many rows returned";
+ }
+
+ void NoRowsReturned::ice_print(std::ostream & s) const
+ {
+ s << "No rows returned";
+ }
+
+ void NoRowsFound::ice_print(std::ostream & s) const
+ {
+ s << "No rows found";
+ }
+
+ void UnsuitableIdFieldType::ice_print(std::ostream & s) const
+ {
+ static boost::format f("Unsuitable id field type [%s]");
+ s << f % type;
+ }
+
+}
+
diff --git a/slicer/db/sqlExceptions.ice b/slicer/db/sqlExceptions.ice
index a392876..3aca6a2 100644
--- a/slicer/db/sqlExceptions.ice
+++ b/slicer/db/sqlExceptions.ice
@@ -4,9 +4,13 @@
#include <common.ice>
module Slicer {
+ ["cpp:ice_print"]
exception TooManyRowsReturned extends DeserializerError {};
+ ["cpp:ice_print"]
exception NoRowsReturned extends DeserializerError {};
+ ["cpp:ice_print"]
exception NoRowsFound extends SerializerError {};
+ ["cpp:ice_print"]
exception UnsuitableIdFieldType extends SerializerError {
string type;
};
diff --git a/slicer/slicer/common.ice b/slicer/slicer/common.ice
index 96d3a85..6960f42 100644
--- a/slicer/slicer/common.ice
+++ b/slicer/slicer/common.ice
@@ -2,27 +2,38 @@
#define SLICER
module Slicer {
+ ["cpp:ice_print"]
exception CompilerError {
string what;
};
+ ["cpp:ice_print"]
exception RuntimeError { };
+ ["cpp:ice_print"]
exception SerializerError extends RuntimeError { };
+ ["cpp:ice_print"]
exception DeserializerError extends RuntimeError { };
+ ["cpp:ice_print"]
exception IncorrectElementName extends DeserializerError {
string name;
};
+ ["cpp:ice_print"]
exception UnsupportedModelType extends RuntimeError { };
+ ["cpp:ice_print"]
exception LocalTypeException extends RuntimeError { };
+ ["cpp:ice_print"]
exception NoConversionFound extends RuntimeError {
string type;
};
+ ["cpp:ice_print"]
exception UnknownType extends DeserializerError {
string type;
};
+ ["cpp:ice_print"]
exception InvalidEnumerationValue extends SerializerError {
int value;
string type;
};
+ ["cpp:ice_print"]
exception InvalidEnumerationSymbol extends DeserializerError {
string symbol;
string type;
diff --git a/slicer/slicer/slicer.cpp b/slicer/slicer/slicer.cpp
index c895a38..ee2a95f 100644
--- a/slicer/slicer/slicer.cpp
+++ b/slicer/slicer/slicer.cpp
@@ -1,4 +1,6 @@
#include "slicer.h"
+#include <common.h>
+#include <boost/format.hpp>
namespace Slicer {
Slicer::MemberChildRef::MemberChildRef(Slicer::ModelPartPtr mp, const Slicer::Metadata & md) :
@@ -35,5 +37,77 @@ namespace Slicer {
{
return emptyMetadata;
}
+
+ void
+ InvalidEnumerationSymbol::ice_print(std::ostream & s) const
+ {
+ static boost::format f("Invalid enumeration symbol [%s] for type [%s]");
+ s << f % symbol % type;
+ }
+
+ void
+ InvalidEnumerationValue::ice_print(std::ostream & s) const
+ {
+ static boost::format f("Invalid enumeration symbol [%d] for type [%s]");
+ s << f % value % type;
+ }
+
+ void
+ UnknownType::ice_print(std::ostream & s) const
+ {
+ static boost::format f("Unknown type [%s]");
+ s << f % type;
+ }
+
+ void
+ NoConversionFound::ice_print(std::ostream & s) const
+ {
+ static boost::format f("No conversion found for type [%s]");
+ s << f % type;
+ }
+
+ void
+ LocalTypeException::ice_print(std::ostream & s) const
+ {
+ s << "Invalid operation on local type";
+ }
+
+ void
+ UnsupportedModelType::ice_print(std::ostream & s) const
+ {
+ s << "Unsupported model type";
+ }
+
+ void
+ IncorrectElementName::ice_print(std::ostream & s) const
+ {
+ static boost::format f("Incorrect element name [%s]");
+ s << f % name;
+ }
+
+ void
+ DeserializerError::ice_print(std::ostream & s) const
+ {
+ s << "General deserializer error";
+ }
+
+ void
+ SerializerError::ice_print(std::ostream & s) const
+ {
+ s << "General serializer error";
+ }
+
+ void
+ RuntimeError::ice_print(std::ostream & s) const
+ {
+ s << "General runtime error";
+ }
+
+ void
+ CompilerError::ice_print(std::ostream & s) const
+ {
+ static boost::format f("Slicer compiler: %s");
+ s << f % what;
+ }
}
diff --git a/slicer/xml/serializer.cpp b/slicer/xml/serializer.cpp
index f83151e..654793c 100644
--- a/slicer/xml/serializer.cpp
+++ b/slicer/xml/serializer.cpp
@@ -8,6 +8,7 @@
#include <boost/intrusive_ptr.hpp>
#include <stdexcept>
#include <glibmm/ustring.h>
+#include <boost/format.hpp>
NAMEDFACTORY(".xml", Slicer::XmlFileSerializer, Slicer::FileSerializerFactory);
NAMEDFACTORY(".xml", Slicer::XmlFileDeserializer, Slicer::FileDeserializerFactory);
@@ -354,5 +355,11 @@ namespace Slicer {
doc = new xmlpp::Document();
modelRoot->OnEachChild(boost::bind(&XmlSerializer::ModelTreeIterateRoot, doc, _1, _2));
}
+
+ void BadBooleanValue::ice_print(std::ostream & s) const
+ {
+ static boost::format f("Bad boolean value [%s]");
+ s << f % text;
+ }
}
diff --git a/slicer/xml/xmlExceptions.ice b/slicer/xml/xmlExceptions.ice
index e03fbe7..94dee30 100644
--- a/slicer/xml/xmlExceptions.ice
+++ b/slicer/xml/xmlExceptions.ice
@@ -4,6 +4,7 @@
#include <common.ice>
module Slicer {
+ ["cpp:ice_print"]
exception BadBooleanValue extends DeserializerError {
string text;
};