summaryrefslogtreecommitdiff
path: root/gjs/jsapi-util-error.cpp
diff options
context:
space:
mode:
authorPhilip Chimento <philip.chimento@gmail.com>2017-09-19 00:03:28 -0700
committerPhilip Chimento <philip.chimento@gmail.com>2017-10-03 22:57:59 -0700
commite23b19ef5ceffc2eaa34821a83c982342d5a08fa (patch)
tree79ca0c507ad6a9dc4d83f3912c05c2d4d1196f06 /gjs/jsapi-util-error.cpp
parent7d9c751db92cb50a75f59e67630cdd488e76bb6f (diff)
downloadgjs-e23b19ef5ceffc2eaa34821a83c982342d5a08fa.tar.gz
jsapi-util: Remove jsapi-private
Ever since removing the gjs-module API, there has not really been a distinction between "public" and "private" jsapi-util functions. Just remove the private files and incorporate everything declared or defined there into the other jsapi-util files.
Diffstat (limited to 'gjs/jsapi-util-error.cpp')
-rw-r--r--gjs/jsapi-util-error.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/gjs/jsapi-util-error.cpp b/gjs/jsapi-util-error.cpp
index 9ee8e71e..7393a689 100644
--- a/gjs/jsapi-util-error.cpp
+++ b/gjs/jsapi-util-error.cpp
@@ -26,6 +26,7 @@
#include "jsapi-util.h"
#include "jsapi-wrapper.h"
#include "gi/gerror.h"
+#include "util/misc.h"
#include <util/log.h>
@@ -232,3 +233,43 @@ gjs_format_stack_trace(JSContext *cx,
return g_filename_from_utf8(stack_utf8, -1, nullptr, nullptr, nullptr);
}
+
+void
+gjs_warning_reporter(JSContext *context,
+ JSErrorReport *report)
+{
+ const char *warning;
+ GLogLevelFlags level;
+
+ g_assert(report);
+
+ if (gjs_environment_variable_is_set("GJS_ABORT_ON_OOM") &&
+ report->flags == JSREPORT_ERROR &&
+ report->errorNumber == 137) {
+ /* 137, JSMSG_OUT_OF_MEMORY */
+ g_error("GJS ran out of memory at %s: %i.",
+ report->filename,
+ report->lineno);
+ }
+
+ if ((report->flags & JSREPORT_WARNING) != 0) {
+ warning = "WARNING";
+ level = G_LOG_LEVEL_MESSAGE;
+
+ /* suppress bogus warnings. See mozilla/js/src/js.msg */
+ if (report->errorNumber == 162) {
+ /* 162, JSMSG_UNDEFINED_PROP: warns every time a lazy property
+ * is resolved, since the property starts out
+ * undefined. When this is a real bug it should usually
+ * fail somewhere else anyhow.
+ */
+ return;
+ }
+ } else {
+ warning = "REPORTED";
+ level = G_LOG_LEVEL_WARNING;
+ }
+
+ g_log(G_LOG_DOMAIN, level, "JS %s: [%s %d]: %s", warning, report->filename,
+ report->lineno, report->message().c_str());
+}