value and error. A result carries one or the other, never both.
On failure,
error is an object with a single message string describing what went wrong.
Check for errors first
Becausevalue is null when a call fails, check error before using value:
"Unknown city".
Why failures don’t stop the script
A failing resource call is something your script can act on: you might fall back to a default, try a different resource or return a friendly message. So a failure is reported in the result, and the script carries on.{ ok: false, reason: live.error.message }.
Mistakes in how a script calls a function, such as a missing argument, a misspelled argument name or a wrongly typed value, aren’t reported in the result. They’re
RuntimeErrors that stop the script. See Using resources.Using the value
value holds a value of the function’s declared return type, and you can use it like any other value:
object produce plain objects. Numbers inside them get inferred types: whole numbers become int32 or int64, and other numbers become decimal.
Functions that return nothing
Some functions perform an action and have no return value. Calling one produces{ value: null, error: null } on success, so you can still check error: