Files
webstudio/packages/error-utils
Bogdan Chadkin 8cb6a2a666 build: upgrade to node v20 (#3217)
Node 20 brings a few cool features
- stable test runner
- recursive readdir
- global crypto.randomUUID()
2024-04-21 13:40:44 +07:00
..

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);
};