Files
webstudio/packages/error-utils
Bogdan Chadkin a58f2eff04 build: run all tests and typechecks in CI (#3661)
Here improved our checks. No longet rely on "checks" script but run
"test" and "typescript" scripts from each package in monorepo.

Would also make each package less boilerplaty.
2024-07-02 18:21:05 +03: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);
};