js: Add utility to improve error message formatting

Previously, when we formatted SyntaxErrors with toString(), they
wouldn't display the file/line/column where the syntax error occurred.
This adds a utility function that performs a more comprehensive
formatting that displays location information for SyntaxErrors, as well
as the .cause property of the error if it is present. This formatting is
equivalent to what we do in gjs-console when logging an error.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3041>
This commit is contained in:
Philip Chimento 2024-01-02 16:16:00 -08:00 committed by Florian Müllner
parent 5fe6e5c865
commit a1a320d3d1
2 changed files with 63 additions and 0 deletions

View file

@ -19,6 +19,7 @@
<file>misc/dateUtils.js</file>
<file>misc/dbusUtils.js</file>
<file>misc/dependencies.js</file>
<file>misc/errorUtils.js</file>
<file>misc/extensionUtils.js</file>
<file>misc/fileUtils.js</file>
<file>misc/gnomeSession.js</file>