@typeship/exception
v0.0.5
Published
An exception class implementation that inherits Error. Useful for TypeScript projects that need to check that an object is an error. See: [the `X instanceof BuiltinConstructor` expression to return `false`](https://github.com/Microsoft/TypeScript/wiki/Bre
Readme
@typeship/exception
An exception class implementation that inherits Error. Useful for TypeScript projects that need to check that an object is an error. See: the X instanceof BuiltinConstructor expression to return false.
Usage
import { Exception } from "@typeship/exception";
class MyException extends Exception {}import { Exception } from "@typeship/exception";
if (process.env["NODE_ENV"] !== "production") {
throw new Exception("This file should not be imported in production");
}import { Exception } from "@typeship/exception";
try {
fn();
} catch (e) {
if (e instanceof Exception) {
// do something
}
}