2.5.28 • Published 4 months ago

@thi.ng/errors v2.5.28

Weekly downloads
4,172
License
Apache-2.0
Repository
github
Last release
4 months 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@allforabit/paths@bnaya/malloc-temporary-fork@cfxjs/errors@fluent-wallet/errors@thi.ng/fibers@thi.ng/fsm@thi.ng/egf@thi.ng/gp@thi.ng/grid-iterators@thi.ng/geom-trace-bitmap@thi.ng/geom-webgl@thi.ng/text-canvas@thi.ng/rstream-graph@thi.ng/server@thi.ng/transducers-binary@thi.ng/transducers@thi.ng/transducers-async@thi.ng/zipper@thi.ng/webgl@thi.ng/wasm-api-webgl@thi.ng/geom-accel@thi.ng/geom@thi.ng/color@thi.ng/color-palettes@thi.ng/csp@thi.ng/compose@thi.ng/cellular@thi.ng/geom-io-obj@thi.ng/geom-poly-utils@thi.ng/geom-sdf@thi.ng/arrays@thi.ng/adjacency@thi.ng/args@thi.ng/buffers@thi.ng/leb128@thi.ng/lowdisc@thi.ng/ksuid@thi.ng/lsys@thi.ng/blurhash@thi.ng/atom@thi.ng/axidraw@thi.ng/bencode@thi.ng/bitfield@thi.ng/bitstream@thi.ng/iterators@thi.ng/k-means@thi.ng/imago@thi.ng/interceptors@thi.ng/intervals@thi.ng/transducers-stats@thi.ng/transducers-patch@thi.ng/units@thi.ng/scenegraph@thi.ng/shader-ast-optimize@thi.ng/shader-ast-glsl@thi.ng/shader-ast@thi.ng/shader-ast-js@thi.ng/soa@thi.ng/sparse@thi.ng/sparse-set@thi.ng/rstream-query@thi.ng/transclude@thi.ng/strings@thi.ng/wasm-api@thi.ng/wasm-api-bindgen@thi.ng/wasm-api-dom@thi.ng/tangle@thi.ng/vector-pools@thi.ng/vectors@thi.ng/dynvar@thi.ng/dsp@thi.ng/ecs@thi.ng/dsp-io-wav@thi.ng/hdom@thi.ng/hdom-canvas@thi.ng/hdom2020@thi.ng/hiccup@thi.ng/idgen@thi.ng/hiccup-markdown@thi.ng/hiccup-css@thi.ng/parse@thi.ng/morton@thi.ng/msgpack@thi.ng/paths@thi.ng/proctext@thi.ng/quad-edge@thi.ng/ramp@thi.ng/pointfree-lang@thi.ng/rstream@thi.ng/router
2.5.28

4 months ago

2.5.27

4 months ago

2.5.25

5 months ago

2.5.26

5 months ago

2.5.24

5 months ago

2.5.23

5 months ago

2.5.22

6 months ago

2.5.21

6 months ago

2.5.20

7 months ago

2.5.19

7 months ago

2.5.18

8 months ago

2.5.8

1 year ago

2.5.9

1 year ago

2.5.14

11 months ago

2.5.15

11 months ago

2.5.16

9 months ago

2.5.17

9 months ago

2.5.10

12 months ago

2.5.11

12 months ago

2.5.12

12 months ago

2.5.13

11 months ago

2.5.7

1 year ago

2.5.6

1 year ago

2.5.5

1 year ago

2.5.4

1 year ago

2.5.3

1 year ago

2.5.2

1 year ago

2.5.1

1 year ago

2.5.0

1 year ago

2.4.20

1 year ago

2.4.19

1 year ago

2.4.18

1 year ago

2.4.17

1 year ago

2.4.16

1 year ago

2.4.14

1 year ago

2.4.13

1 year ago

2.4.15

1 year ago

2.4.12

1 year ago

2.4.11

1 year ago

2.4.10

1 year ago

2.4.9

2 years ago

2.4.7

2 years ago

2.4.8

2 years ago

2.4.6

2 years ago

2.4.5

2 years ago

2.4.4

2 years ago

2.4.1

2 years ago

2.4.0

2 years ago

2.4.3

2 years ago

2.4.2

2 years ago

2.3.0

2 years ago

2.3.2

2 years ago

2.3.1

2 years ago

2.3.4

2 years ago

2.3.3

2 years ago

2.3.6

2 years ago

2.3.5

2 years ago

2.2.17

2 years ago

2.2.16

2 years ago

2.2.15

2 years ago

2.2.13

2 years ago

2.2.14

2 years ago

2.2.12

2 years ago

2.2.11

2 years ago

2.2.10

2 years ago

2.2.9

2 years ago

2.2.7

3 years ago

2.2.6

3 years ago

2.2.8

2 years ago

2.2.1

3 years ago

2.2.3

3 years ago

2.2.2

3 years ago

2.2.5

3 years ago

2.2.4

3 years ago

2.2.0

3 years ago

2.1.9

3 years ago

2.1.10

3 years ago

2.1.8

3 years ago

2.1.6

3 years ago

2.1.7

3 years ago

2.1.5

3 years ago

2.1.4

3 years ago

2.1.2

4 years ago

2.1.1

4 years ago

2.1.3

4 years ago

2.1.0

4 years ago

2.0.4

4 years ago

2.0.6

4 years ago

2.0.3

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.3.4

4 years ago

1.3.3

4 years ago

1.3.2

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.32

4 years ago

1.2.28

4 years ago

1.2.29

4 years ago

1.2.30

4 years ago

1.2.31

4 years ago

1.2.27

4 years ago

1.2.26

4 years ago

1.2.25

5 years ago

1.2.24

5 years ago

1.2.23

5 years ago

1.2.22

5 years ago

1.2.21

5 years ago

1.2.20

5 years ago

1.2.19

5 years ago

1.2.18

5 years ago

1.2.17

5 years ago

1.2.16

5 years ago

1.2.15

5 years ago

1.2.14

5 years ago

1.2.13

5 years ago

1.2.12

5 years ago

1.2.11

5 years ago

1.2.10

5 years ago

1.2.9

5 years ago

1.2.8

5 years ago

1.2.7

5 years ago

1.2.6

5 years ago

1.2.5

5 years ago

1.2.4

5 years ago

1.2.3

5 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.1.12

7 years ago

0.1.11

7 years ago

0.1.10

7 years ago

0.1.9

7 years ago

0.1.8

7 years ago

0.1.7

7 years ago

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.1

7 years ago