Chalk home page
  1. Resolvers
  2. Errors

Resolvers can raise errors in the course of executing, and handle errors in resolving other feature values.

Raising errors

If your resolver fails by raising an exception, the error will be surfaced as a ChalkError in query responses. Clients will receive a null value for the feature, and by default, downstream resolvers won’t run.

Handling errors

By default, if there was an error in computing one of the inputs to a resolver, that resolver will also fail with the error code UPSTREAM_FAILED. To handle failures in the input features, take as input the feature value, but wrapped in typing.Optional:

from typing import Optional

def fn(score: Optional[User.fraud_score]) -> ...:

The argument score will receive the value None in the case of a failure.

If you’d like to provide a default value to use in the case of a failure, you can use Python’s syntax for assigning a default value to an argument:

def fn(score: Optional[User.fraud_score] = -1) -> ...: