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>
This commit is contained in:
parent
21e4cb142d
commit
03025d7cff
@ -268,6 +268,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…
Reference in New Issue
Block a user