2.5.6 • Published 5 days ago

@thi.ng/errors v2.5.6

Weekly downloads
4,172
License
Apache-2.0
Repository
github
Last release
5 days ago

errors

npm version npm downloads Twitter Follow

This project is part of the @thi.ng/umbrella monorepo.

About

Custom error types and error factory functions.

This package defines the following error types & helper functions to throw them:

Custom error types can be easily defined using defError().

Status

STABLE - used in production

Search or submit any issues for this package

Installation

yarn add @thi.ng/errors

ES module import:

<script type="module" src="https://cdn.skypack.dev/@thi.ng/errors"></script>

Skypack documentation

For Node.js REPL:

# with flag only for < v16
node --experimental-repl-await

> const errors = await import("@thi.ng/errors");

Package sizes (gzipped, pre-treeshake): ESM: 538 bytes

Dependencies

None

API

Generated API docs

import * as err from "@thi.ng/errors";

err.illegalArity(3)
// Error: illegal arity: 3

err.illegalArgs("expected foo");
// Error: illegal argument(s): expected foo

err.illegalState("oops");
// Error: illegal state: oops

err.unsupported("TODO not yet implemented")
// Error: unsupported operation: TODO not yet implemented

// define custom error
const MyError = err.defError(
    () => "Eeek... ",
    (x) => x + " is not allowed!"
);

try {
    throw new MyError(23);
} catch(e) {
    console.warn(e.message);
    console.log(e instanceof Error);
}
// Eeek... 23 is not allowed!
// true

Environment variables

The UMBRELLA_ASSERTS or SNOWPACK_PUBLIC_UMBRELLA_ASSERTS env variables are used to control the behavior of the assert() function in production builds: If either is set (to a non-empty string), the function will always be enabled. Otherwise (by default), assert() will be disabled for production builds, i.e. if process.env.NODE_ENV === "production".

Authors

Karsten Schmidt

If this project contributes to an academic publication, please cite it as:

@misc{thing-errors,
  title = "@thi.ng/errors",
  author = "Karsten Schmidt",
  note = "https://thi.ng/errors",
  year = 2018
}

License

© 2018 - 2021 Karsten Schmidt // Apache Software License 2.0

@bnaya/malloc-fork-experimental@allforabit/csp@allforabit/interceptors@allforabit/resolve-map@allforabit/router@allforabit/rstream@allforabit/transducers@allforabit/associative@allforabit/rstream-query@everything-registry/sub-chunk-914@thi.ng/hdom2020@thi.ng/hiccup-css@thi.ng/hiccup@thi.ng/hdom-canvas@thi.ng/vectors@thi.ng/wasm-api-dom@thi.ng/wasm-api-bindgen@thi.ng/vector-pools@thi.ng/wasm-api@thi.ng/zipper@thi.ng/webgl@thi.ng/geom-io-obj@thi.ng/geom-poly-utils@thi.ng/random@thi.ng/ramp@thi.ng/pointfree-lang@thi.ng/quad-edge@thi.ng/dsp@thi.ng/dsp-io-wav@thi.ng/ecs@thi.ng/egf@thi.ng/fsm@thi.ng/fibers@thi.ng/geom@thi.ng/geom-accel@thi.ng/dgraph@thi.ng/dcons@thi.ng/distance@thi.ng/defmulti@thi.ng/dynvar@shinyoshiaki/umbrella-bitstream@thi.ng/bitstream@thi.ng/blurhash@thi.ng/buffers@thi.ng/cellular@thi.ng/color@thi.ng/color-palettes@thi.ng/compose@thi.ng/csp@thi.ng/bitfield@thi.ng/rstream@thi.ng/rdom@thi.ng/rle-pack@thi.ng/router@thi.ng/resolve-map@thi.ng/rstream-query@thi.ng/rstream-graph@thi.ng/shader-ast@thi.ng/shader-ast-glsl@thi.ng/scenegraph@thi.ng/idgen@thi.ng/imago@thi.ng/iterators@thi.ng/k-means@thi.ng/ksuid@thi.ng/interceptors@thi.ng/intervals@thi.ng/hiccup-markdown@thi.ng/morton@thi.ng/msgpack@thi.ng/paths@thi.ng/pointfree@thi.ng/parse@thi.ng/pixel@thi.ng/pixel-io-netpbm@thi.ng/pixel-io-pfm@thi.ng/grid-iterators@thi.ng/hdom@thi.ng/geom-sdf@thi.ng/geom-trace-bitmap@thi.ng/gp@thi.ng/units@thi.ng/transducers-stats@thi.ng/transducers@thi.ng/transducers-async@thi.ng/transducers-patch@thi.ng/transducers-binary@thi.ng/text-canvas@thi.ng/bencode@thi.ng/arrays@thi.ng/adjacency@thi.ng/args@thi.ng/atom@thi.ng/associative@thi.ng/axidraw@thi.ng/leb128@thi.ng/lowdisc@thi.ng/lsys@thi.ng/meta-css@thi.ng/malloc
2.5.6

5 days ago

2.5.5

7 days ago

2.5.4

16 days ago

2.5.3

19 days ago

2.5.2

1 month ago

2.5.1

1 month ago

2.5.0

2 months ago

2.4.20

2 months ago

2.4.19

2 months ago

2.4.18

2 months ago

2.4.17

2 months ago

2.4.16

3 months ago

2.4.14

3 months ago

2.4.13

3 months ago

2.4.15

3 months ago

2.4.12

3 months ago

2.4.11

3 months ago

2.4.10

4 months ago

2.4.9

4 months ago

2.4.7

4 months ago

2.4.8

4 months ago

2.4.6

5 months ago

2.4.5

5 months ago

2.4.4

5 months ago

2.4.1

6 months ago

2.4.0

6 months ago

2.4.3

5 months ago

2.4.2

6 months ago

2.3.0

9 months ago

2.3.2

9 months ago

2.3.1

9 months ago

2.3.4

8 months ago

2.3.3

9 months ago

2.3.6

6 months ago

2.3.5

8 months ago

2.2.17

11 months ago

2.2.16

12 months ago

2.2.15

1 year ago

2.2.13

1 year ago

2.2.14

1 year ago

2.2.12

1 year ago

2.2.11

1 year ago

2.2.10

1 year ago

2.2.9

1 year ago

2.2.7

1 year ago

2.2.6

1 year ago

2.2.8

1 year ago

2.2.1

2 years ago

2.2.3

1 year ago

2.2.2

2 years ago

2.2.5

1 year ago

2.2.4

1 year ago

2.2.0

2 years ago

2.1.9

2 years ago

2.1.10

2 years ago

2.1.8

2 years ago

2.1.6

2 years ago

2.1.7

2 years ago

2.1.5

2 years ago

2.1.4

2 years ago

2.1.2

2 years ago

2.1.1

2 years ago

2.1.3

2 years ago

2.1.0

2 years ago

2.0.4

3 years ago

2.0.6

2 years ago

2.0.3

3 years ago

2.0.2

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.3.4

3 years ago

1.3.3

3 years ago

1.3.2

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.32

3 years ago

1.2.28

3 years ago

1.2.29

3 years ago

1.2.30

3 years ago

1.2.31

3 years ago

1.2.27

3 years ago

1.2.26

3 years ago

1.2.25

3 years ago

1.2.24

3 years ago

1.2.23

3 years ago

1.2.22

4 years ago

1.2.21

4 years ago

1.2.20

4 years ago

1.2.19

4 years ago

1.2.18

4 years ago

1.2.17

4 years ago

1.2.16

4 years ago

1.2.15

4 years ago

1.2.14

4 years ago

1.2.13

4 years ago

1.2.12

4 years ago

1.2.11

4 years ago

1.2.10

4 years ago

1.2.9

4 years ago

1.2.8

4 years ago

1.2.7

4 years ago

1.2.6

4 years ago

1.2.5

4 years ago

1.2.4

4 years ago

1.2.3

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.2.0

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.1.12

5 years ago

0.1.11

6 years ago

0.1.10

6 years ago

0.1.9

6 years ago

0.1.8

6 years ago

0.1.7

6 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.1

6 years ago