changeset 107:57a47f76c5e4

Irccd: fix missing error on plugin failures
author David Demelier <markand@malikania.fr>
date Wed, 27 Apr 2016 07:37:00 +0200
parents 8e7ddb14965e
children af84dd3d585b
files lib/irccd/plugin.cpp
diffstat 1 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/lib/irccd/plugin.cpp	Wed Apr 27 07:36:42 2016 +0200
+++ b/lib/irccd/plugin.cpp	Wed Apr 27 07:37:00 2016 +0200
@@ -57,8 +57,16 @@
 	} else {
 		/* Call the function and discard the result */
 		duk::insert(m_context, -nargs - 1);
-		duk::pcall(m_context, nargs);
-		duk::pop(m_context);
+
+		if (duk::pcall(m_context, nargs) != 0) {
+			auto error = duk::error(m_context, -1);
+
+			duk::pop(m_context);
+
+			throw error;
+		} else {
+			duk::pop(m_context);
+		}
 	}
 }