{"id":883,"date":"2022-01-18T16:24:41","date_gmt":"2022-01-18T16:24:41","guid":{"rendered":"https:\/\/logicbuilder.integroscrm.com\/help\/?page_id=883"},"modified":"2022-06-10T10:01:05","modified_gmt":"2022-06-10T10:01:05","slug":"throw-exception","status":"publish","type":"page","link":"https:\/\/logicbuilder.integroscrm.com\/help\/throw-exception\/","title":{"rendered":"Throw Exception"},"content":{"rendered":"\n<p><a name=\"abstract\"><\/a>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.<\/p>\n\n\n\n<p>Allows addressing the challenges of data validation. For example, when data comes through API to Sugar from an external system \u2013 prior to applying changes or saving a record you could implement additional rules, and return an error when rules are violated.<\/p>\n\n\n\n<p><strong>inputs:<\/strong><br><br><span style=\"color:#b197cb;\">error code<\/span> &#8211; input numeric code of an error that is going to be returned to the Requester.<\/p>\n\n\n<div style=\"background-color: #ddeaff; border-left: 6px solid #0072b3; padding: 12px;\">\n<p>For validation rules, use error code 422<\/p>\n<\/div>\n\n\n<ul class=\"wp-block-list\"><li>Required: yes<\/li><\/ul>\n\n\n\n<p><span style=\"color:#9ed267;\">error label<\/span> &#8211; input additional description to the numeric code, e.g. missing_parameter or invalid_parameter<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Required: no<\/li><\/ul>\n\n\n\n<p><span style=\"color:#9ed267;\">error message<\/span> &#8211; input human-readable message, e.g. &#8220;Provide Purchase number to sent the Quote&#8221;<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Required: no<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/logicbuilder.integroscrm.com\/help\/wp-content\/uploads\/2021\/12\/img-52-5f052a9f2fa64623a46f52687e77e32e.png\" alt=\"\" class=\"wp-image-482\" width=\"296\" height=\"264\" srcset=\"https:\/\/logicbuilder.integroscrm.com\/help\/wp-content\/uploads\/2021\/12\/img-52-5f052a9f2fa64623a46f52687e77e32e.png 413w, https:\/\/logicbuilder.integroscrm.com\/help\/wp-content\/uploads\/2021\/12\/img-52-5f052a9f2fa64623a46f52687e77e32e-300x267.png 300w\" sizes=\"auto, (max-width: 296px) 100vw, 296px\" \/><\/figure>\n\n\n\n<p><strong>Example of usage<\/strong><\/p>\n\n\n\n<p>Let\u2019s say that Quotes with \u201cDiscount Amount\u201d 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.<\/p>\n\n\n\n<p>So the flowchart which implements all sets of checks ends with Throw Exception when conditions aren\u2019t met:<\/p>\n\n\n<p><a href=\"https:\/\/logicbuilder.integroscrm.com\/help\/wp-content\/uploads\/2021\/12\/img-52-026cbf3368714125abf3869f379736c6.png\" rel=\"prettyPhoto\"><img decoding=\"async\" src=\"https:\/\/logicbuilder.integroscrm.com\/help\/wp-content\/uploads\/2021\/12\/img-52-026cbf3368714125abf3869f379736c6-1024x400.png\" alt=\"\" class=\"wp-image-378\"><\/a><\/p>\n\n\n<p>As a result, when criteria of the rule is violated, a user sees the following error in the interface:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/logicbuilder.integroscrm.com\/help\/wp-content\/uploads\/2021\/12\/img-52-7ddc9faba86448368afdcfcc704a4990.png\" alt=\"\" class=\"wp-image-484\" width=\"447\" height=\"180\" srcset=\"https:\/\/logicbuilder.integroscrm.com\/help\/wp-content\/uploads\/2021\/12\/img-52-7ddc9faba86448368afdcfcc704a4990.png 611w, https:\/\/logicbuilder.integroscrm.com\/help\/wp-content\/uploads\/2021\/12\/img-52-7ddc9faba86448368afdcfcc704a4990-300x121.png 300w\" sizes=\"auto, (max-width: 447px) 100vw, 447px\" \/><\/figure>\n\n\n\n<p>External Clients get the following error in the API response:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/logicbuilder.integroscrm.com\/help\/wp-content\/uploads\/2021\/12\/img-52-073ae253a1d64d52b56590c0e717131a-1024x234.png\" alt=\"\" class=\"wp-image-486\" width=\"808\" height=\"185\" srcset=\"https:\/\/logicbuilder.integroscrm.com\/help\/wp-content\/uploads\/2021\/12\/img-52-073ae253a1d64d52b56590c0e717131a-1024x234.png 1024w, https:\/\/logicbuilder.integroscrm.com\/help\/wp-content\/uploads\/2021\/12\/img-52-073ae253a1d64d52b56590c0e717131a-300x68.png 300w, https:\/\/logicbuilder.integroscrm.com\/help\/wp-content\/uploads\/2021\/12\/img-52-073ae253a1d64d52b56590c0e717131a-768x175.png 768w, https:\/\/logicbuilder.integroscrm.com\/help\/wp-content\/uploads\/2021\/12\/img-52-073ae253a1d64d52b56590c0e717131a.png 1428w\" sizes=\"auto, (max-width: 808px) 100vw, 808px\" \/><\/figure>\n<div style=\"text-align:left\" class=\"yasr-auto-insert-visitor\"><!--Yasr Visitor Votes Shortcode--><div id='yasr_visitor_votes_883' class='yasr-visitor-votes'><div class=\"yasr-custom-text-vv-before yasr-custom-text-vv-before-883\">Click to rate this post!<\/div><div id='yasr-vv-second-row-container-040cff8b69e97' \n                                        class='yasr-vv-second-row-container'><div id='yasr-visitor-votes-rater-040cff8b69e97'\n                                      class='yasr-rater-stars-vv'\n                                      data-rater-postid='883' \n                                      data-rating='0'\n                                      data-rater-starsize='24'\n                                      data-rater-readonly='false'\n                                      data-rater-nonce='fa81b01ba5' \n                                      data-issingular='false'\n                                    ><\/div><div class=\"yasr-vv-stats-text-container\" id=\"yasr-vv-stats-text-container-040cff8b69e97\"><svg xmlns=\"https:\/\/www.w3.org\/2000\/svg\" width=\"20\" height=\"20\" \n                               class=\"yasr-dashicons-visitor-stats\"\n                               data-postid=\"883\" \n                               id=\"yasr-stats-dashicon-040cff8b69e97\">\n                            <path d=\"M18 18v-16h-4v16h4zM12 18v-11h-4v11h4zM6 18v-8h-4v8h4z\"><\/path>\n                          <\/svg><span id=\"yasr-vv-text-container-040cff8b69e97\" class=\"yasr-vv-text-container\">[Total: <span id=\"yasr-vv-votes-number-container-040cff8b69e97\">0<\/span>  Average: <span id=\"yasr-vv-average-container-040cff8b69e97\">0<\/span>]<\/span><\/div><div id='yasr-vv-loader-040cff8b69e97' class='yasr-vv-container-loader'><\/div><\/div><div id='yasr-vv-bottom-container-040cff8b69e97' class='yasr-vv-bottom-container'><\/div><\/div><!--End Yasr Visitor Votes Shortcode--><\/div>","protected":false},"excerpt":{"rendered":"<p>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 &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"https:\/\/logicbuilder.integroscrm.com\/help\/throw-exception\/\"> <span class=\"screen-reader-text\">Throw Exception<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"yasr_overall_rating":0,"yasr_post_is_review":"","yasr_auto_insert_disabled":"","yasr_review_type":"","footnotes":""},"tags":[],"class_list":["post-883","page","type-page","status-publish","hentry"],"yasr_visitor_votes":{"number_of_votes":0,"sum_votes":0,"stars_attributes":{"read_only":false,"span_bottom":false}},"_links":{"self":[{"href":"https:\/\/logicbuilder.integroscrm.com\/help\/wp-json\/wp\/v2\/pages\/883","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/logicbuilder.integroscrm.com\/help\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/logicbuilder.integroscrm.com\/help\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/logicbuilder.integroscrm.com\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/logicbuilder.integroscrm.com\/help\/wp-json\/wp\/v2\/comments?post=883"}],"version-history":[{"count":3,"href":"https:\/\/logicbuilder.integroscrm.com\/help\/wp-json\/wp\/v2\/pages\/883\/revisions"}],"predecessor-version":[{"id":1710,"href":"https:\/\/logicbuilder.integroscrm.com\/help\/wp-json\/wp\/v2\/pages\/883\/revisions\/1710"}],"wp:attachment":[{"href":"https:\/\/logicbuilder.integroscrm.com\/help\/wp-json\/wp\/v2\/media?parent=883"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/logicbuilder.integroscrm.com\/help\/wp-json\/wp\/v2\/tags?post=883"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}