@webstudio-is/error-utils

0.189.0 • Public • Published

Error utils

API

captureError(error, value)

  • Provides a compile error when value is not never
  • Throws a runtime error in development synchronously to break intentionally
  • Throws an error in production asynchronously to not break unintentionally
import { captureError } from "error-utils";

const fn = (value: { type: string }) => {
  if (value.type === "foo") {
    return value;
  }

  return captureError(new Error("Should never happen"), value);
};

Dependencies (0)

    Dev Dependencies (2)

    Package Sidebar

    Install

    npm i @webstudio-is/error-utils

    Homepage

    webstudio.is

    Weekly Downloads

    89

    Version

    0.189.0

    License

    AGPL-3.0-or-later

    Unpacked Size

    36.5 kB

    Total Files

    5

    Last publish

    Collaborators

    • trysound
    • kof