JsError

object JsError

Utility for wrapping JavaScript error types.

Functions

Link copied to clipboard
inline fun error(msg: String, cause: Throwable? = null, errno: Int? = null, vararg extraProps: Pair<String, Any>): Nothing

Manufacture a generic JavaScript error with the provided msg and optional cause.

Link copied to clipboard
fun <R : Any> jsErrors(op: () -> R): R

TBD.

Link copied to clipboard
fun of(msg: String, errno: Int? = null, vararg extraProps: Pair<String, Any>): Error

Manufacture a generic JavaScript error with the provided msg and optional cause.

fun of(msg: String, cause: Throwable?, errno: Int? = null, vararg extraProps: Pair<String, Any>): Error

Manufacture a generic JavaScript error with the provided msg and optional cause.

Link copied to clipboard
fun rangeError(message: String, cause: Throwable? = null, raise: Boolean = false): RangeError

RangeError convenience function: wrap the provided message and optional cause; then, optionally raise.

Link copied to clipboard
fun typeError(error: Throwable, raise: Boolean = false): TypeError

TypeError convenience function: wrap the provided error and optionally raise.

fun typeError(message: String, cause: Throwable? = null, raise: Boolean = false): TypeError

TypeError convenience function: wrap the provided message and optional cause; then, optionally raise.

fun typeError(code: String, message: String, cause: Throwable? = null, raise: Boolean = false): TypeError

TypeError constructor for spec-compliant type errors which accept a code and message.

Link copied to clipboard
fun valueError(error: Throwable, raise: Boolean = false): ValueError

ValueError convenience function: wrap the provided error and optionally raise.

fun valueError(message: String, cause: Throwable? = null, raise: Boolean = false): ValueError

ValueError convenience function: wrap the provided error and optionally raise.

Link copied to clipboard
fun wrap(throwable: Throwable, type: KClass<out Error>? = null): Error

Wrap a caught throwable in a JavaScript error; if no error type is specified, a ValueError will be raised.