aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/parser.cpp
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2013-05-12 13:57:34 +0200
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2014-02-15 15:21:53 +0100
commitabfabda5f54ac903bc990340a684e14e5e2b68a5 (patch)
tree1f736cc477f4a90214f01f1a3586aee7e5282b84 /src/parser.cpp
parent161b624b4f27a994a33e427d2b5646d80afd0822 (diff)
downloadsciteco-abfabda5f54ac903bc990340a684e14e5e2b68a5.tar.gz
glib allocation functions throw std::bad_alloc exceptions now; catch all bad_allocs and convert them to State::Error
* will allow some degree of OOM handling * currently does not work since the exception specifications prevent bad_allocs from propagating. exception specification usage must be completely revised
Diffstat (limited to 'src/parser.cpp')
-rw-r--r--src/parser.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/parser.cpp b/src/parser.cpp
index 8921942..f64b246 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -21,6 +21,7 @@
#include <stdarg.h>
#include <string.h>
+#include <stdexcept>
#include <glib.h>
#include <glib/gprintf.h>
@@ -83,10 +84,16 @@ Execute::step(const gchar *macro, gint stop_pos)
#endif
try {
- if (interface.is_interrupted())
- throw State::Error("Interrupted");
-
- State::input(macro[macro_pc]);
+ /* convert bad_alloc exceptions */
+ try {
+ if (interface.is_interrupted())
+ throw State::Error("Interrupted");
+
+ State::input(macro[macro_pc]);
+ } catch (std::bad_alloc &alloc) {
+ throw State::Error("bad_alloc: %s",
+ alloc.what());
+ }
} catch (State::Error &error) {
error.pos = macro_pc;
String::get_coord(macro, error.pos,