Skip to content

RuntimeError

Built-in class · Extends Error

A RuntimeError is what Emerald raises when the program asks for something that cannot be done: a position outside a list, dividing by zero, a number too large for an Int, or any other error marked Raises in these pages.

const values = [1, 2]
try {
print(values[5])
}
catch error: RuntimeError {
print(error.message) # prints index 5 is outside this list, which has 2 elements
}

message: String

What went wrong, in words.

Each part of the standard library raises its own kind of RuntimeError, so a program can handle one kind of problem without catching every other: FileError, DateTimeError, RegexError, JsonError, CsvError, HttpError, EncodingError, InputError, RecursionError, and DeadlockError. Catching RuntimeError catches all of them.