From e4691d271704784824b6d97ae4b3d4bd9bf11fee Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Sat, 2 Dec 2023 10:27:20 -0800 Subject: [PATCH] dbusServices/extensions: Improve error message formatting See https://gitlab.gnome.org/GNOME/gjs/-/issues/584 for a user report. This uses the new formatter added in the previous commit to format errors in the extension preferences loader. Part-of: --- .../extensions/extensionPrefsDialog.js | 15 +++++---------- .../org.gnome.Shell.Extensions.src.gresource.xml | 1 + 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/js/dbusServices/extensions/extensionPrefsDialog.js b/js/dbusServices/extensions/extensionPrefsDialog.js index 50b2e92f5..334640d5e 100644 --- a/js/dbusServices/extensions/extensionPrefsDialog.js +++ b/js/dbusServices/extensions/extensionPrefsDialog.js @@ -7,6 +7,8 @@ import GLib from 'gi://GLib'; import GObject from 'gi://GObject'; import Gtk from 'gi://Gtk?version=4.0'; +import {formatError} from './misc/errorUtils.js'; + export const ExtensionPrefsDialog = GObject.registerClass({ GTypeName: 'ExtensionPrefsDialog', Signals: { @@ -120,21 +122,14 @@ const ExtensionPrefsErrorPage = GObject.registerClass({ this._revealer.connect('notify::child-revealed', () => this._syncExpandedStyle()); - this._errorView.buffer.text = `${error}\n\nStack trace:\n`; - // Indent stack trace. - this._errorView.buffer.text += - error.stack.split('\n').map(line => ` ${line}`).join('\n'); + const formattedError = formatError(error); + this._errorView.buffer.text = formattedError; // markdown for pasting in gitlab issues let lines = [ `The settings of extension ${this._uuid} had an error:`, '```', - `${error}`, - '```', - '', - 'Stack trace:', - '```', - error.stack.replace(/\n$/, ''), // stack without trailing newline + formattedError.replace(/\n$/, ''), // remove trailing newline '```', '', ]; diff --git a/js/dbusServices/org.gnome.Shell.Extensions.src.gresource.xml b/js/dbusServices/org.gnome.Shell.Extensions.src.gresource.xml index 55be1d199..5db7b115f 100644 --- a/js/dbusServices/org.gnome.Shell.Extensions.src.gresource.xml +++ b/js/dbusServices/org.gnome.Shell.Extensions.src.gresource.xml @@ -10,6 +10,7 @@ extensions/prefs.js misc/config.js + misc/errorUtils.js misc/extensionUtils.js misc/dbusUtils.js misc/params.js