[gjs: 11/15] jsapi-util: Remove return value of gjs_log_exception_full()
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 11/15] jsapi-util: Remove return value of gjs_log_exception_full()
- Date: Sun, 16 Jan 2022 21:28:17 +0000 (UTC)
commit 2998df39e816e65af6f18f4e8b26fbf1fb5e5bb8
Author: Philip Chimento <philip chimento gmail com>
Date: Sat Jan 15 10:20:11 2022 -0800
jsapi-util: Remove return value of gjs_log_exception_full()
The documentation of gjs_log_exception_full() wasn't correct in that it
claimed to return false if no exception was pending, but it never actually
checked that. In fact it is used in logError() to log an exception that is
not pending, so this documentation was just incorrect.
Add the documentation instead to gjs_log_exception() where it belongs.
gjs/jsapi-util.cpp | 15 ++++++++++-----
gjs/jsapi-util.h | 2 +-
2 files changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/gjs/jsapi-util.cpp b/gjs/jsapi-util.cpp
index bf5210c09..57956189b 100644
--- a/gjs/jsapi-util.cpp
+++ b/gjs/jsapi-util.cpp
@@ -356,10 +356,8 @@ std::string gjs_value_debug_string(JSContext* context, JS::HandleValue value) {
*
* Currently, uses %G_LOG_LEVEL_WARNING if the exception is being printed after
* being caught, and %G_LOG_LEVEL_CRITICAL if it was not caught by user code.
- *
- * Returns: %true if an exception was logged, %false if there was none pending.
*/
-bool gjs_log_exception_full(JSContext* context, JS::HandleValue exc,
+void gjs_log_exception_full(JSContext* context, JS::HandleValue exc,
JS::HandleString message, GLogLevelFlags level) {
JS::AutoSaveExceptionState saved_exc(context);
const GjsAtoms& atoms = GjsContextPrivate::atoms(context);
@@ -465,10 +463,17 @@ bool gjs_log_exception_full(JSContext* context, JS::HandleValue exc,
}
saved_exc.restore();
-
- return true;
}
+/**
+ * gjs_log_exception:
+ * @cx: the #JSContext
+ *
+ * Logs the exception pending on @cx, if any, in response to an exception being
+ * thrown that user code cannot catch or has already caught.
+ *
+ * Returns: %true if an exception was logged, %false if there was none pending.
+ */
bool
gjs_log_exception(JSContext *context)
{
diff --git a/gjs/jsapi-util.h b/gjs/jsapi-util.h
index 76747552e..1300eaaf5 100644
--- a/gjs/jsapi-util.h
+++ b/gjs/jsapi-util.h
@@ -440,7 +440,7 @@ bool gjs_log_exception (JSContext *context);
bool gjs_log_exception_uncaught(JSContext* cx);
-bool gjs_log_exception_full(JSContext* cx, JS::HandleValue exc,
+void gjs_log_exception_full(JSContext* cx, JS::HandleValue exc,
JS::HandleString message, GLogLevelFlags level);
[[nodiscard]] std::string gjs_value_debug_string(JSContext* cx,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]