Skip to main content
Module

x/denops_std/helper/mod.ts>friendlyCall

📚 Standard module for denops.vim
Go to Latest
function friendlyCall
import { friendlyCall } from "https://deno.land/x/denops_std@v4.1.6/helper/mod.ts";

Call given function and print a friendly error message (without stack trace) on failure.

It's mainly designed for dispatcher functions. Print a stack trace when denops is running in debug mode.

import { Denops } from "../mod.ts";
import { friendlyCall } from "../helper/mod.ts";

export async function main(denops: Denops): Promise<void> {
  denops.dispatcher = {
    say: () => {
      return friendlyCall(denops, async () => {
        // Do whatever you want.
        throw new Error("Some error occurred");
      });
    },
  };
}

Parameters

denops: Denops
fn: () => Promise<unknown>

Returns

Promise<unknown>