Skip to Content
API reference

Error

A JavaScript error object or any JVM Throwable. new Error(message) constructs the shared runtime error class.

Valuesstandard library

Type mapping

TypeScriptJVMNotes
new Error(message)typescriptnative.ErrorConstructed by TypeScript, thrown to Java as a RuntimeException.
Errorjava.lang.ThrowableEvery Throwable is an Error in TypeScript.

Error interface

interface Error

A JavaScript error object or any JVM Throwable. new Error(message) constructs the shared runtime typescriptnative.Error. TypeScript catches it as unknown until narrowed.

Properties

message: string
namereadonly
readonly name: string

Error for a typed Error, the JavaScript name for an npm error, RangeError for a StackOverflowError or OutOfMemoryError, and the Java class name for other JVM exceptions.

stackreadonly
readonly stack?: string

The JavaScript stack of an npm error, or the JVM frames.

Methods

toString(): string

name, then : message when both are not empty, as in string concatenation. Java callers keep Throwable.toString().

ErrorConstructor interface

interface ErrorConstructor

Constructors

new (message?: string): Error

Generated when the website builds, from lib.tsn.d.ts.

Language

Remembered on every API page

On this page