Handle errors returned from Seshat (#30083)
* Handle errors returned from Seshat Fix a bug which caused errors from Seshat to be swallowed, giving only "Unknown error". * fix type casting
This commit is contained in:
@@ -11,7 +11,7 @@ import { type ElectronChannel } from "../../@types/global";
|
|||||||
|
|
||||||
interface IPCPayload {
|
interface IPCPayload {
|
||||||
id?: number;
|
id?: number;
|
||||||
error?: string;
|
error?: string | { message: string };
|
||||||
reply?: any;
|
reply?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,7 +53,12 @@ export class IPCManager {
|
|||||||
const callbacks = this.pendingIpcCalls[payload.id];
|
const callbacks = this.pendingIpcCalls[payload.id];
|
||||||
delete this.pendingIpcCalls[payload.id];
|
delete this.pendingIpcCalls[payload.id];
|
||||||
if (payload.error) {
|
if (payload.error) {
|
||||||
callbacks.reject(payload.error);
|
// `seshat.ts` sends a JavaScript object with a `message` property. Turn it into a proper Error.
|
||||||
|
let error = payload.error;
|
||||||
|
if (typeof error === "object" && error.message) {
|
||||||
|
error = new Error(error.message);
|
||||||
|
}
|
||||||
|
callbacks.reject(error);
|
||||||
} else {
|
} else {
|
||||||
callbacks.resolve(payload.reply);
|
callbacks.resolve(payload.reply);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user