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.
AggregateErrorCreates an instance representing several errors wrapped in a single error when multiple errors need to be reported by an operation, for example byPromise.any().EvalErrorCreates an instance representing an error that occurs regarding the global functioneval().RangeErrorCreates an instance representing an error that occurs when a numeric variable or parameter is outside of its valid range.ReferenceErrorCreates an instance representing an error that occurs when de-referencing an invalid reference.SyntaxErrorCreates an instance representing a syntax error.TypeErrorCreates an instance representing an error that occurs when a variable or parameter is not of a valid type.URIErrorCreates 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
valueis or has a defaultErrortype tag.
const { TypeTags } = require('typetags')
let error = new Error('Bam!')
TypeTags.isError(error.toString())// → false
TypeTags.isError(error)// → trueMetadata (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}