From e23b19ef5ceffc2eaa34821a83c982342d5a08fa Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Tue, 19 Sep 2017 00:03:28 -0700 Subject: 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. --- gjs/jsapi-util-error.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'gjs/jsapi-util-error.cpp') 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 @@ -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()); +} -- cgit v1.2.1