»Language: Logging and Errors

The built-in functions print and error can be used for logging and errors. Logging is helpful to understand how a policy is executing in development. And errors are useful to halting execution immediately in certain scenarios.


The print function is used to output debug information. The exact location where this print statements go is dependent on the host application and the Sentinel runtime itself.

The print function takes one or more Sentinel values as arguments. Each value is formatted for human-friendly output and space-separated. Example:

value = 42
print("the value is", value) // the value is 42

map = { "foo": false }
print(map) // { "foo": false }

one_is_zero = rule { 1 == 0 }
print(one_is_zero) // false


Certain actions in Sentinel, such as accessing an undefined variable, attempting to add two incompatible types, etc. result in runtime errors. These errors halt the execution of a policy immediately. The pass/fail result of a policy is considered fail.

Runtime errors can be manually triggered using the error function. The error function behaves exactly like the print function except that execution is halted immediately.

This should only be used in scenarios where the policy must fail due to some unexpected or invalid condition. The line between error and undefined can sometimes be unclear. Undefined is recommended when a policy can conceivably recover or safely ignore the undefined behavior. An error should be used when the policy should fail and notify someone regardless.