Skip to content

Commit 2312c62

Browse files
authored
Merge pull request #374 from vim-denops/improve-call-error-message
👍 Improve error message of `call`
2 parents 3864494 + 40c0a34 commit 2312c62

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

denops/@denops-private/service.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,14 @@ class Plugin {
173173
}
174174

175175
async call(fn: string, ...args: unknown[]): Promise<unknown> {
176-
return await this.#denops.dispatcher[fn](...args);
176+
try {
177+
return await this.#denops.dispatcher[fn](...args);
178+
} catch (err) {
179+
const errMsg = err.message ?? err;
180+
throw new Error(
181+
`Failed to call '${fn}' API in '${this.name}': ${errMsg}`,
182+
);
183+
}
177184
}
178185
}
179186

denops/@denops-private/service_test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ Deno.test("Service", async (t) => {
311311
],
312312
});
313313
assert(typeof err === "string");
314-
assertMatch(err, /invalid call/);
314+
assertMatch(err, /Failed to call 'test' API in 'dummy': invalid call/);
315315
} finally {
316316
s.restore();
317317
}

0 commit comments

Comments
 (0)