TypeTags .Error
Overview
Error
objects are thrown when runtime errors occur. The Error
object can also be used as a base object for user-defined exceptions. See below for standard built-in error types.
AggregateError
Creates an instance representing several errors wrapped in a single error when multiple errors need to be reported by an operation, for example byPromise.any()
.EvalError
Creates an instance representing an error that occurs regarding the global functioneval()
.RangeError
Creates an instance representing an error that occurs when a numeric variable or parameter is outside of its valid range.ReferenceError
Creates an instance representing an error that occurs when de-referencing an invalid reference.SyntaxError
Creates an instance representing a syntax error.TypeError
Creates an instance representing an error that occurs when a variable or parameter is not of a valid type.URIError
Creates an instance representing an error that occurs whenencodeURI()
ordecodeURI()
are passed invalid parameters.
Usage
import { TypeTags } from 'typetags'
try { throw new Error('Whoops!')} catch (e) { console.error(e.name + ': ' + e.message)}
TypeTags.get(new Error('Bam!'))// → [object Error]
Predicate
TypeTags.isError(value)
- Checks if
value
is or has a defaultError
type tag.
const { TypeTags } = require('typetags')
let error = new Error('Bam!')
TypeTags.isError(error.toString())// → false
TypeTags.isError(error)// → true
Metadata (TType)
Metadata | Value |
---|---|
.type | Error |
.tag | [object Error] |
.builtin() | undefined |
.getTag() | [object Error] |
.hasSpecialArgs() | false |
.instance() | undefined |
.instanceTypeOf() | object |
.info() | see more |
.isAvailable() | true |
.isConstructor() | true |
.isFactory() | true |
.isFunction() | true |
.isGlobal() | true |
.isIterator() | false |
.isNested() | false |
.isObject() | false |
.isPrimitive() | false |
.isStringifiable() | true |
.isSyntatic() | false |
.isTypedArray() | false |
.ownKeys() | [length, name, prototype, captureStackTrace, stackTraceLimit, prepareStackTrace] |
.toString() | function toString() { [native code] } |
.typeOf() | function |
Signature
declare type ITypeTags = { [key in Types | NestedTypes]: Tags}
declare interface Predicate { predicate(value: any): boolean}