Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
blueslip_stacktrace: Handle thrown null or undefined.
Anders Kaseorg34d3b2302e36
diff --git a/web/src/blueslip.ts b/web/src/blueslip.tsindex c4d760e34ec..66c8dbe698b 100644--- a/web/src/blueslip.ts+++ b/web/src/blueslip.ts@@ -112,7 +112,7 @@ if (DEVELOPMENT) {$(window).on("error", (event: JQuery.TriggeredEvent) => {const {originalEvent} = event;if (originalEvent instanceof ErrorEvent) {- void display_stacktrace(originalEvent.error);+ void display_stacktrace(originalEvent.error, originalEvent.message);}});$(window).on("unhandledrejection", (event: JQuery.TriggeredEvent) => {diff --git a/web/src/blueslip_stacktrace.ts b/web/src/blueslip_stacktrace.tsindex 4f894fdbc63..9907edde037 100644--- a/web/src/blueslip_stacktrace.ts+++ b/web/src/blueslip_stacktrace.ts@@ -109,19 +109,21 @@ async function get_context(location: StackFrame): Promise<NumberedLine[] | undef}));}-export async function display_stacktrace(ex: unknown): Promise<void> {+export async function display_stacktrace(ex: unknown, message?: string): Promise<void> {const errors = [];do {if (!(ex instanceof Error)) {- const prototype: unknown = Object.getPrototypeOf(ex);+ let prototype: unknown;errors.push({name:- typeof prototype === "object" &&+ ex !== null &&+ ex !== undefined &&+ typeof (prototype = Object.getPrototypeOf(ex)) === "object" &&prototype !== null &&"constructor" in prototype? `thrown ${prototype.constructor.name}`: "thrown",- message: String(ex),+ message: ex === undefined ? message : String(ex),stackframes: [],});break;