TypeTags .SyntaxError

Overview

The SyntaxError object represents an error when trying to interpret syntactically invalid code. It is thrown when the JavaScript engine encounters tokens or token order that does not conform to the syntax of the language when parsing code.

️🚫

Since error objects do not have unique type tags, a SyntaxError type tag is the same as any other Error object. If you need to check if an error is an instance of a SyntaxError, use instanceof instead.

Usage

import { TypeTags } from 'typetags'
try {
throw new SyntaxError('Hello', 'someFile.js', 10)
} catch (e) {
console.error(e instanceof SyntaxError) // true
console.error(e.message) // Hello
console.error(e.name) // SyntaxError
console.error(e.fileName) // someFile.js
console.error(e.lineNumber) // 10
console.error(e.columnNumber) // 0
console.error(e.stack) // @debugger eval code:3:9
}
console.log(TypeTags.SyntaxError)
// → [object Error]

Metadata (TType)

MetadataValue
.typeSyntaxError
.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]
.toString()function toString() { [native code] }
.typeOf()function

Signature

declare type ITypeTags = {
[key in Types | NestedTypes]: Tags
}
declare interface Predicate {
predicate(value: any): boolean
}

See MDN Web Docs