shithub: libmujs

Download patch

ref: 49271d3cf2fbdb165f09238666d9e7aa91f1305f
parent: 222772f6bbd042801e7eefeb3aee8ecfc2113f6e
author: Tor Andersson <tor.andersson@artifex.com>
date: Tue Jul 3 08:00:51 EDT 2018

Add js_iserror function.

--- a/jsrun.c
+++ b/jsrun.c
@@ -224,6 +224,12 @@
 	return 0;
 }
 
+int js_iserror(js_State *J, int idx)
+{
+	js_Value *v = stackidx(J, idx);
+	return v->type == JS_TOBJECT && v->u.object->type == JS_CERROR;
+}
+
 static const char *js_typeof(js_State *J, int idx)
 {
 	js_Value *v = stackidx(J, idx);
--- a/mujs.h
+++ b/mujs.h
@@ -174,6 +174,7 @@
 int js_iscoercible(js_State *J, int idx);
 int js_iscallable(js_State *J, int idx);
 int js_isuserdata(js_State *J, int idx, const char *tag);
+int js_iserror(js_State *J, int idx);
 
 int js_toboolean(js_State *J, int idx);
 double js_tonumber(js_State *J, int idx);