From 29c03c2309ad8a5ba66653d67c463b61053bde0d Mon Sep 17 00:00:00 2001 From: Shougo Matsushita Date: Mon, 19 Jun 2023 07:23:48 +0900 Subject: [PATCH] Add errorException --- denops/ddu/ddu.ts | 23 +---------------------- denops/ddu/utils.ts | 25 ++++++++++++++++++++++++- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/denops/ddu/ddu.ts b/denops/ddu/ddu.ts index 8ea16f9..391b7f0 100644 --- a/denops/ddu/ddu.ts +++ b/denops/ddu/ddu.ts @@ -73,7 +73,7 @@ import { defaultColumnOptions } from "./base/column.ts"; import { defaultKindOptions } from "./base/kind.ts"; import { defaultActionOptions } from "./base/action.ts"; import { Loader } from "./loader.ts"; -import { treePath2Filename } from "./utils.ts"; +import { errorException, treePath2Filename } from "./utils.ts"; type GatherState = { items: DduItem[]; @@ -2024,27 +2024,6 @@ async function checkColumnOnInit( } } -async function errorException(denops: Denops, e: unknown, message: string) { - await denops.call( - "ddu#util#print_error", - message, - ); - if (e instanceof Error) { - await denops.call( - "ddu#util#print_error", - e.message, - ); - if (e.stack) { - await denops.call( - "ddu#util#print_error", - e.stack, - ); - } - } else { - console.log(e); - } -} - async function globpath( denops: Denops, search: string, diff --git a/denops/ddu/utils.ts b/denops/ddu/utils.ts index 78036a2..b377d60 100644 --- a/denops/ddu/utils.ts +++ b/denops/ddu/utils.ts @@ -1,6 +1,29 @@ -import { pathsep } from "./deps.ts"; +import { Denops, pathsep } from "./deps.ts"; import { TreePath } from "./types.ts"; export function treePath2Filename(treePath: TreePath) { return typeof treePath === "string" ? treePath : treePath.join(pathsep); } + +export async function errorException( + denops: Denops, + e: unknown, + message: string, +) { + await denops.call( + "ddu#util#print_error", + message, + ); + if (e instanceof Error) { + await denops.call( + "ddu#util#print_error", + e.message, + ); + if (e.stack) { + await denops.call( + "ddu#util#print_error", + e.stack, + ); + } + } +}