Skip to content

Commit

Permalink
fix: detect unexpected item to stringify
Browse files Browse the repository at this point in the history
  • Loading branch information
jchip committed Apr 9, 2020
1 parent d20e7e2 commit 7228817
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/electrode-react-webapp/lib/render-output.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,13 @@ class Output {
for (const x of this._items) {
if (typeof x === "string") {
out += x;
} else {
} else if (x && x.stringify) {
out += x.stringify();
} else {
const typeName = (x && x.constructor && x.constructor.name) || typeof x;
const msg = `SpotOutput unable to stringify item of type ${typeName}`;
console.error("FATAL Error:", msg + "\n"); // eslint-disable-line
throw new Error(msg);
}
}
return out;
Expand Down

0 comments on commit 7228817

Please sign in to comment.