throw() raises the given exception. Execution stops unless a surrounding try/catch block catches it.
exception MyException(string)
let result = try {
throw(MyException("Out of milk"))
} catch {
| MyException(message) => "Caught exception: " ++ message
}
To throw a JavaScript Error instead of a ReScript exception, use JsError.throwWithMessage or the other functions in JsError.