mirror of
https://github.com/edu4rdshl/gnome-shell.git
synced 2026-07-17 23:24:51 +00:00
lookingGlass: Handle unprintable object
We currently throw an error when encountering a result that cannot
be represented as string, with the prompt appearing somewhat stuck
(the input cannot be committed).
Showing a lame fallback instead at least avoids that issue. When
the object has a typeof 'object' but is not an instanceof Object,
we are likely dealing with an ES module, and can show a slightly
less lame fallback.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2842>
(cherry picked from commit 03025d7cff)
This commit is contained in:
parent
c51f8f5742
commit
1dc56854a5
1 changed files with 5 additions and 0 deletions
|
|
@ -261,6 +261,11 @@ function objectToString(o) {
|
|||
if (typeof o == typeof objectToString) {
|
||||
// special case this since the default is way, way too verbose
|
||||
return '<js function>';
|
||||
} else if (o && o.toString === undefined) {
|
||||
// eeks, something unprintable. we'll have to guess, probably a module
|
||||
return typeof o === 'object' && !(o instanceof Object)
|
||||
? '<module>'
|
||||
: '<unknown>';
|
||||
} else {
|
||||
return `${o}`;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue