Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/main/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,10 @@ export function initialize() {
try {
return valueToMeta(event.sender, contextId, func(...args), true)
} catch (error) {
const err = new Error(`Could not call remote function '${func.name || 'anonymous'}'. Check that the function signature is correct. Underlying error: ${error.message}\nUnderlying stack: ${error.stack}\n`);
const err = new Error(
`Could not call remote function '${func.name || "anonymous"}'. Check that the function signature is correct. Underlying error: ${error}\n` +
(error instanceof Error ? `Underlying stack: ${error.stack}\n` : "")
);
(err as any).cause = error
throw err
}
Expand Down Expand Up @@ -495,7 +498,10 @@ export function initialize() {
try {
return valueToMeta(event.sender, contextId, object[method](...args), true)
} catch (error) {
const err = new Error(`Could not call remote method '${method}'. Check that the method signature is correct. Underlying error: ${error.message}\nUnderlying stack: ${error.stack}\n`);
const err = new Error(
`Could not call remote method '${method}'. Check that the method signature is correct. Underlying error: ${error}` +
(error instanceof Error ? `Underlying stack: ${error.stack}\n` : "")
);
(err as any).cause = error
throw err
}
Expand Down
2 changes: 1 addition & 1 deletion test/all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,7 @@ describe('remote module', () => {
try {
throwFunction(new Error('error from main'))
expect.fail()
} catch (e) {
} catch (e: any) {
expect(e.message).to.match(/Could not call remote function/)
expect(e.cause.message).to.equal('error from main')
}
Expand Down