-
Notifications
You must be signed in to change notification settings - Fork 0
API Error
Liu.Yandong.Hanks edited this page Aug 19, 2026
·
3 revisions
脚本错误值
Script error value
Error 用于创建可 throw 的错误值。运行时会保留错误消息和脚本调用栈,适合向调用方说明无法继续执行的条件。
Errorcreates values that can bethrown. The runtime retains the message and script call stack, making it suitable for reporting a condition from which the caller cannot continue.
Parameters:
-
message
描述错误原因的字符串。String describing the failure.
Returns
可抛出的 Error 值。
A throwable
Errorvalue.
func requirePositive(value) {
if (value <= 0) throw new Error("value must be positive");
return value;
}
return requirePositive(3);边界行为
仅在确实无法恢复时抛出;预期的“未找到”结果通常更适合返回 null 或约定值。
Throw only for unrecoverable conditions; an expected "not found" result is usually better represented by
nullor an agreed value.
AuroraScript.JIT 4.0.0 · Documentation Home · Repository · MIT License