From 6f22e2dc9689bb13070a13ddae8be3f3600eeb20 Mon Sep 17 00:00:00 2001 From: Shougo Matsushita Date: Sun, 7 Jul 2024 13:55:19 +0900 Subject: [PATCH] Remove TimeoutError --- denops/ddc/deps.ts | 1 - denops/ddc/ext.ts | 62 ++++++++++++++++------------------------------ 2 files changed, 22 insertions(+), 41 deletions(-) diff --git a/denops/ddc/deps.ts b/denops/ddc/deps.ts index d67fd20..fe21d49 100644 --- a/denops/ddc/deps.ts +++ b/denops/ddc/deps.ts @@ -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"; diff --git a/denops/ddc/ext.ts b/denops/ddc/ext.ts index b17fd6c..1e89005 100644 --- a/denops/ddc/ext.ts +++ b/denops/ddc/ext.ts @@ -1,4 +1,4 @@ -import { deadline, DeadlineError, Denops, TimeoutError } from "./deps.ts"; +import { deadline, DeadlineError, Denops } from "./deps.ts"; import { BaseFilter, BaseFilterParams, @@ -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`, + ); } } @@ -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`, + ); } } @@ -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`, + ); } } @@ -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( @@ -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( @@ -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( @@ -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 @@ -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( @@ -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( @@ -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; }