Skip to content

Commit

Permalink
Remove TimeoutError
Browse files Browse the repository at this point in the history
  • Loading branch information
Shougo committed Jul 7, 2024
1 parent c1c46e5 commit 6f22e2d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 41 deletions.
1 change: 0 additions & 1 deletion denops/ddc/deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,5 @@ export { basename, parse, toFileUrl } from "jsr:@std/path@0.225.2";
export { deadline, DeadlineError } from "jsr:@std/async@0.224.2";
export { spy } from "jsr:@std/testing@0.225.3/mock";

export { TimeoutError } from "https://deno.land/x/msgpack_rpc@v4.0.1/response_waiter.ts";
export { ensure, is } from "jsr:@core/unknownutil@3.18.1";
export { Lock } from "jsr:@lambdalisue/async@2.1.1";
62 changes: 22 additions & 40 deletions denops/ddc/ext.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { deadline, DeadlineError, Denops, TimeoutError } from "./deps.ts";
import { deadline, DeadlineError, Denops } from "./deps.ts";
import {
BaseFilter,
BaseFilterParams,
Expand Down Expand Up @@ -536,15 +536,11 @@ async function checkUiOnInit(

ui.isInitialized = true;
} catch (e: unknown) {
if (isTimeoutError(e)) {
// Ignore timeout error
} else {
await printError(
denops,
e,
`ui: ${ui.name} "onInit()" failed`,
);
}
await printError(
denops,
e,
`ui: ${ui.name} "onInit()" failed`,
);
}
}

Expand Down Expand Up @@ -577,15 +573,11 @@ async function checkSourceOnInit(
);
}
} catch (e: unknown) {
if (isTimeoutError(e)) {
// Ignore timeout error
} else {
await printError(
denops,
e,
`source: ${source.name} "onInit()" failed`,
);
}
await printError(
denops,
e,
`source: ${source.name} "onInit()" failed`,
);
}
}

Expand All @@ -608,15 +600,11 @@ async function checkFilterOnInit(

filter.isInitialized = true;
} catch (e: unknown) {
if (isTimeoutError(e)) {
// Ignore timeout error
} else {
await printError(
denops,
e,
`filter: ${filter.name} "onInit()" failed`,
);
}
await printError(
denops,
e,
`filter: ${filter.name} "onInit()" failed`,
);
}
}

Expand Down Expand Up @@ -645,7 +633,7 @@ async function callSourceOnEvent(
loader,
});
} catch (e: unknown) {
if (isTimeoutError(e) || isDdcCallbackCancelError(e)) {
if (isDdcCallbackCancelError(e)) {
// Ignore timeout error
} else {
await printError(
Expand Down Expand Up @@ -685,7 +673,7 @@ async function callSourceOnCompleteDone<
userData: userData as any,
});
} catch (e: unknown) {
if (isTimeoutError(e) || isDdcCallbackCancelError(e)) {
if (isDdcCallbackCancelError(e)) {
// Ignore timeout error
} else {
await printError(
Expand Down Expand Up @@ -718,7 +706,7 @@ export async function callSourceGetCompletePosition(
sourceParams,
});
} catch (e: unknown) {
if (isTimeoutError(e) || isDdcCallbackCancelError(e)) {
if (isDdcCallbackCancelError(e)) {
// Ignore timeout error
} else {
await printError(
Expand Down Expand Up @@ -765,7 +753,7 @@ export async function callSourceGather<
return await deadline(source.gather(args), sourceOptions.timeout);
} catch (e: unknown) {
if (
isTimeoutError(e) || isDdcCallbackCancelError(e) ||
isDdcCallbackCancelError(e) ||
e instanceof DeadlineError
) {
// Ignore timeout error
Expand Down Expand Up @@ -804,7 +792,7 @@ async function callFilterOnEvent(
filterParams,
});
} catch (e: unknown) {
if (isTimeoutError(e) || isDdcCallbackCancelError(e)) {
if (isDdcCallbackCancelError(e)) {
// Ignore timeout error
} else {
await printError(
Expand Down Expand Up @@ -841,7 +829,7 @@ export async function callFilterFilter(
items,
});
} catch (e: unknown) {
if (isTimeoutError(e) || isDdcCallbackCancelError(e)) {
if (isDdcCallbackCancelError(e)) {
// Ignore timeout error
} else {
await printError(
Expand All @@ -855,12 +843,6 @@ export async function callFilterFilter(
}
}

// isinstanceof may be failed
// https://zenn.dev/luma/articles/2e891a24fe099c
function isTimeoutError(e: unknown): e is TimeoutError {
return (e as TimeoutError).name === "TimeoutError";
}

function source2Name(s: UserSource) {
return typeof s === "string" ? s : s.name;
}
Expand Down

0 comments on commit 6f22e2d

Please sign in to comment.