From 03025d7cff68800507ac14766f99ad54c247bb3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Thu, 13 Jul 2023 00:25:43 +0200 Subject: [PATCH] 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: --- js/ui/lookingGlass.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/js/ui/lookingGlass.js b/js/ui/lookingGlass.js index 6063b1740..05006d837 100644 --- a/js/ui/lookingGlass.js +++ b/js/ui/lookingGlass.js @@ -268,6 +268,11 @@ function objectToString(o) { if (typeof o == typeof objectToString) { // special case this since the default is way, way too verbose return ''; + } else if (o && o.toString === undefined) { + // eeks, something unprintable. we'll have to guess, probably a module + return typeof o === 'object' && !(o instanceof Object) + ? '' + : ''; } else { return `${o}`; }