Bixby Developer Center

Guides

Error Handling

This capsule demonstrates how to handle errors in your actions.

Download Capsule

Note

Because you cannot submit a capsule with the example namespace, in order to test a sample capsule on a device, you must change the id in the capsule.bxb file from example to your organization's before making a private submission.

For example, if your namespace is acme, change example.errorHandling to acme.errorHandling.

In Bixby Language, errors thrown by JavaScript can be caught with a throws block that specifies an error type along with an on-catch block that specifies an effect used for handling the error.

This capsule demonstrates several error-handling effects. To see them in action, execute the specified intent.

  • drop drops an input (the integer specified below) and re-executes the plan.

      intent {
    goal: GetResultDrop
    value: Integer(1)
    }

    See GetResultDrop.model.bxb and GetResultDrop.js.

  • halt stops execution of the plan.

      intent {
    goal: GetResultHalt
    }

    See GetResultHalt.model.bxb and GetResultHalt.js.

  • replan specifies a new intent and goal in the on-catch block.

      intent {
    goal: GetResultReplan
    }

    See GetResultReplan.model.bxb and GetResultReplan.js. The replan specifies a new intent with a goal of Result and a route of GetResult; see GetResult.model.bxb and GetResult.js.

Other effects that can be used in error handling include prompt, replace, unlock, and flag-as-off-topic. These are implemented in similar fashion. For details about their operation, see the effects documentation.