Files
webstudio/packages/error-utils
Jaya Krishna Namburu 3c8c40a24d build: Release v0.102.0 to npm (#2382)
## Description

Releasing `0.102.0` to npm.

## Code Review

- [ ] hi @kof, I need you to do
  - detailed review (read every line)
2023-09-26 19:45:51 +02: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);
};