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: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3041>
This commit is contained in:
parent
e6f35c5e88
commit
e4691d2717
@ -7,6 +7,8 @@ import GLib from 'gi://GLib';
|
|||||||
import GObject from 'gi://GObject';
|
import GObject from 'gi://GObject';
|
||||||
import Gtk from 'gi://Gtk?version=4.0';
|
import Gtk from 'gi://Gtk?version=4.0';
|
||||||
|
|
||||||
|
import {formatError} from './misc/errorUtils.js';
|
||||||
|
|
||||||
export const ExtensionPrefsDialog = GObject.registerClass({
|
export const ExtensionPrefsDialog = GObject.registerClass({
|
||||||
GTypeName: 'ExtensionPrefsDialog',
|
GTypeName: 'ExtensionPrefsDialog',
|
||||||
Signals: {
|
Signals: {
|
||||||
@ -120,21 +122,14 @@ const ExtensionPrefsErrorPage = GObject.registerClass({
|
|||||||
this._revealer.connect('notify::child-revealed',
|
this._revealer.connect('notify::child-revealed',
|
||||||
() => this._syncExpandedStyle());
|
() => this._syncExpandedStyle());
|
||||||
|
|
||||||
this._errorView.buffer.text = `${error}\n\nStack trace:\n`;
|
const formattedError = formatError(error);
|
||||||
// Indent stack trace.
|
this._errorView.buffer.text = formattedError;
|
||||||
this._errorView.buffer.text +=
|
|
||||||
error.stack.split('\n').map(line => ` ${line}`).join('\n');
|
|
||||||
|
|
||||||
// markdown for pasting in gitlab issues
|
// markdown for pasting in gitlab issues
|
||||||
let lines = [
|
let lines = [
|
||||||
`The settings of extension ${this._uuid} had an error:`,
|
`The settings of extension ${this._uuid} had an error:`,
|
||||||
'```',
|
'```',
|
||||||
`${error}`,
|
formattedError.replace(/\n$/, ''), // remove trailing newline
|
||||||
'```',
|
|
||||||
'',
|
|
||||||
'Stack trace:',
|
|
||||||
'```',
|
|
||||||
error.stack.replace(/\n$/, ''), // stack without trailing newline
|
|
||||||
'```',
|
'```',
|
||||||
'',
|
'',
|
||||||
];
|
];
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
<file>extensions/prefs.js</file>
|
<file>extensions/prefs.js</file>
|
||||||
|
|
||||||
<file>misc/config.js</file>
|
<file>misc/config.js</file>
|
||||||
|
<file>misc/errorUtils.js</file>
|
||||||
<file>misc/extensionUtils.js</file>
|
<file>misc/extensionUtils.js</file>
|
||||||
<file>misc/dbusUtils.js</file>
|
<file>misc/dbusUtils.js</file>
|
||||||
<file>misc/params.js</file>
|
<file>misc/params.js</file>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user