This guide presents use cases where you may experience an exception and provides suggestions to solve it.
Even if an expression is syntactically correct, it may throw an error during execution. These are called exceptions.
They can be caused by many reasons. For instance, consider the following example:
def json = parse_json["result"]
It outputs an exception due to a wrong argument passed to the Rel built-in relation parse_json.
"result" does not follow the expected JSON structure.
Another source of exceptions is nonconvergent computation, which is common when you are using recursion.
For instance, you may experience an unbound domain, i.e., recursive computations where there is no fixpoint or a fixpoint that takes infinitely many iterations to reach.
This happens in the following example where you compute the factorial but do not state the fixpoint
def F = 1 def F[n] = n * F[n-1]
This is the returned output:
You can find out more about these issues in this section of the Recursion concept guide.
Finally, Rel ungrounded variables also return exceptions as error messages. Refer to the Ungrounded Variable Error guide for further details.
Generally, to handle the exception, you need to solve the error underneath that is throwing it. See List of RAI Errors for more details.
Note that the RAI Console helps you detect errors by displaying some information related to the error in the
The same happens when using the SDKs.
Refer to the Result Structure section of any SDK to learn more about it.