Error
A JavaScript error object or any JVM Throwable. new Error(message) constructs the shared runtime error class.
typescriptnative.ErrorArtifact: com.margelo:typescript-native-stdlibType mapping
| TypeScript | JVM | Notes |
|---|---|---|
new Error(message) | typescriptnative.Error | Constructed by TypeScript, thrown to Java as a RuntimeException. |
Error | java.lang.Throwable | Every Throwable is an Error in TypeScript. |
Error class
public class Error extends RuntimeExceptionAn error that JavaScript created: new Error(message) in TypeScript or in a compiled npm module. It owns the state of its own property message. TypeScript, the compiled JavaScript of every project that uses this class and Java read and write this one state, so a change made through any of them is seen by all, for as long as the error lives. Every other Throwable is a JVM exception, whose message TypeScript and JavaScript can only read.
Constructors
Methods
String getMessage()error.message as a string, for TypeScript, Java and Kotlin. A stored string is one field read on any thread. A message that a getter computes runs the getter once, in the realm of the object that has it, and returns its result. A value that is not a string throws a TypeError; nothing is converted. So this method can throw what the getter throws and the TypeError. It never returns null, and a subclass cannot override it.
void setMessage(String value)Strict typed assignment. A null string is stored as an empty string.
String jsName()The typed name: the source object's name, or the default name for a typed construction.
String toString()The class name, then : and the message when it is not empty. A stored string and a getter are read as getMessage() reads them, so a getter runs and what it throws propagates. A data value that is not a string prints the class name only, as Error.prototype.toString prints only the name for an undefined message; no TypeError.
Error.TypeError class
public static class TypeError extends ErrorJavaScript's TypeError.
Constructors
Methods
String defaultName()Generated when the website builds, from Error.java.