Exception Handling

The build configuration can be faulty in many ways:

  • The structure of the build object is invalid
  • The properties of the blocks are invalid
  • The values of the properties are invalid

In the next sections we will go about the different types of errors that can occur and how to handle them. Each section contains the unique error code you receive - check the exception handling section for more information about exception and their unique exception codes.

Block property validation exception

Error code: RIDDLE_BUILDER_BLOCK_PROPERTY_VALUE_VALIDATION

This error occurs when the value of a property of a block is invalid. The response will contain a validationErrors array with all the errors that occurred.

Example

In this example a Predictor we use a build config in which the title is not a string and the items property is missing.

The API returns the following:

{
    "success": false,
    "code": 400,
    "error": "RIDDLE_BUILDER_BLOCK_PROPERTY_VALUE_VALIDATION",
    "message": "PredictorPickTheWinnerBlock: Block properties are invalid. See the validation errors for more details.",
    "validationErrors": [
        {
            "message": "Input is not a string.",
            "code": "NOT_STRING",
            "property": "title"
        },
        {
            "message": "Property \"items\" is required but not set",
            "code": "REQUIRED",
            "property": "items"
        }
    ],
}

As you can see the main message of the error gives you a hint about which block is causing the issue. To learn more about the error you can check the validationErrors array; each validation error contains a message, code, and property.

Block property value invalid

Error code: RIDDLE_BUILDER_BLOCK_PROPERTY_VALUE_INVALID

This happens if the validation of the properties succeeded but when creating the block the values are invalid. There are too many possible errors to list them all here, but the error message will give you a hint about what went wrong.

Example

Adding an integration with a name which does not exist:

{
    "success": false,
    "code": 400,
    "error": "RIDDLE_BUILDER_BLOCK_PROPERTY_VALUE_INVALID",
    "message": "Cannot add 'webhook' integration with name 'webhook.riddle.com' to Riddle as it does not exist",
}

Block type missing

If we try to build a Riddle without setting the type property in a Riddle block the API will return the following error:

{
    "success": false,
    "code": 400,
    "error": "RIDDLE_BUILDER_BLOCK_TYPE_MISSING",
    "message": "PredictorBuilder: No block type found in block config.",
}

In this case the PredictorBuilder throws the exception. This can happen with other embedded blocks as well, e.g. the result page builder blocks: