Skip to content

Commit

Permalink
Add errorException
Browse files Browse the repository at this point in the history
  • Loading branch information
Shougo committed Jun 18, 2023
1 parent 0658fe0 commit 29c03c2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 23 deletions.
23 changes: 1 addition & 22 deletions denops/ddu/ddu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down Expand Up @@ -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,
Expand Down
25 changes: 24 additions & 1 deletion denops/ddu/utils.ts
Original file line number Diff line number Diff line change
@@ -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,
);
}
}
}

0 comments on commit 29c03c2

Please sign in to comment.