Throw Exception

Returns exception as a result of execution. After the exception, there is no way to add other operators, as the flow stops after Throw Exception. It allows to output an error into Sugar interface to users and in the API as well.

Allows addressing the challenges of data validation. For example, when data comes through API to Sugar from an external system – prior to applying changes or saving a record you could implement additional rules, and return an error when rules are violated.

inputs:

error code – input numeric code of an error that is going to be returned to the Requester.

For validation rules, use error code 422

  • Required: yes

error label – input additional description to the numeric code, e.g. missing_parameter or invalid_parameter

  • Required: no

error message – input human-readable message, e.g. “Provide Purchase number to sent the Quote”

  • Required: no

Example of usage

Let’s say that Quotes with “Discount Amount” more than 20% must be approved by Manager. To implement this rule, a Quote must not be moved forward prior to the approval either by a user or by API request.

So the flowchart which implements all sets of checks ends with Throw Exception when conditions aren’t met:

As a result, when criteria of the rule is violated, a user sees the following error in the interface:

External Clients get the following error in the API response:

Click to rate this post!
[Total: 0 Average: 0]

Leave a Reply

Your email address will not be published. Required fields are marked *