<snapdata remixID="13471855"><project name="Library: Catch Errors" app="Snap! 9.0, https://snap.berkeley.edu" version="2"><notes></notes><thumbnail>data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAAB4CAYAAAB1ovlvAAAAAXNSR0IArs4c6QAAAzlJREFUeF7t10FKY2EQhdFfUXDiFtyPGxB0oAbcidvJJrIeceIkBAevwVkPlOZy6QI5GaeqyHkfPHK2bdu2fAgMCZwJcEje2S8BAQphVECAo/yOC1ADowICHOV3XIAaGBUQ4Ci/4wLUwKiAAEf5HRegBkYFBDjK77gANTAqIMBRfscFqIFRAQGO8jsuQA2MCghwlN9xAWpgVECAo/yOC1ADowICHOV3XIAaGBUQ4Ci/4wLUwKiAAEf5HRegBkYFBDjK77gANTAqIMBRfscFqIFRAQGO8jsuQA2MCghwlN9xAWpgVECAo/yOC1ADowICHOV3XIAaGBUQ4Ci/4wLUwKiAAEf5HRegBkYFBDjK77gANTAqIMBRfscFqIFRAQGO8jsuQA2MCghwlN9xAWpgVECAo/yOC1ADowICHOV3XIAaGBUQ4Ci/4wLUwKiAAL/h3+/36/39fd3e3q6bm5vRh/Sbjwvwm6f78fGxXl5e1ufn53p7e1v39/fr4uJiPT09raurq9/cxH/9bQL8gftwOKzX19d1fX3917eOx+N6fn5e27Z9hemTCwgwCPB0Oq3Hx8d1fn6+7u7ucn2TS4D/+Ap+eHj4egXvdrt1eXkpnZKAAP0JKaWUrRFg5maqJCDAEqQ1mYAAMzdTJQEBliCtyQQEmLmZKgkIsARpTSYgwMzNVElAgCVIazIBAWZupkoCAixBWpMJCDBzM1USEGAJ0ppMQICZm6mSgABLkNZkAgLM3EyVBARYgrQmExBg5maqJCDAEqQ1mYAAMzdTJQEBliCtyQQEmLmZKgkIsARpTSYgwMzNVElAgCVIazIBAWZupkoCAixBWpMJCDBzM1USEGAJ0ppMQICZm6mSgABLkNZkAgLM3EyVBARYgrQmExBg5maqJCDAEqQ1mYAAMzdTJQEBliCtyQQEmLmZKgkIsARpTSYgwMzNVElAgCVIazIBAWZupkoCAixBWpMJCDBzM1USEGAJ0ppMQICZm6mSgABLkNZkAgLM3EyVBARYgrQmExBg5maqJCDAEqQ1mYAAMzdTJQEBliCtyQQEmLmZKgkIsARpTSYgwMzNVElAgCVIazIBAWZupkoCfwBN/Be3THjJawAAAABJRU5ErkJggg==</thumbnail><scenes select="1"><scene name="Library: Catch Errors"><notes></notes><hidden></hidden><headers></headers><code></code><blocks><block-definition s="safely try %&apos;action&apos; then if %&apos;error&apos; %&apos;handler&apos;" type="command" category="control"><comment x="0" y="0" w="276" collapsed="false">Catch errors.&#xD;&#xD;Runs the first script.  If it succeeds, nothing else happens.&#xD;But if it has an error (something that would otherwise result&#xD;in a red halo around the block), then the second script is run,&#xD;with the text of the error message that would have been shown in the variable ERROR.</comment><header></header><code></code><translations>pt:tenta executar _ e, em caso de erro _ , executa _&#xD;ca:prova de forma segura _ i si _ _&#xD;</translations><inputs><input type="%cs"></input><input type="%upvar"></input><input type="%cs"></input></inputs><script><block s="doApplyExtension"><l>err_try(cmd, catch, err)</l><list><block var="action"/><block var="handler"/><block var="error"/></list></block><block s="doApplyExtension"><l>err_reset</l><list></list></block></script></block-definition><block-definition s="error %&apos;msg&apos;" type="command" category="control"><comment x="0" y="0" w="268.6666666666667" collapsed="false">Throw an error.&#xD;&#xD;Makes a red halo appear around the script that runs it,&#xD;with the input text shown in a speech balloon next to&#xD;the script, just like any Snap! error.&#xD;&#xD;This is useful to put in the second script of SAFELY TRY&#xD;after some other instructions to undo the partial work of&#xD;the first script.</comment><header></header><code></code><translations>pt:lança o erro _&#xD;</translations><inputs><input type="%txt"></input></inputs><script><block s="doApplyExtension"><l>err_error(msg)</l><list><block var="msg"/></list></block></script></block-definition><block-definition s="safely try reporting %&apos;this&apos; then if %&apos;error&apos; report %&apos;that&apos;" type="reporter" category="control"><comment x="0" y="0" w="316.6666666666667" collapsed="false">Catch errors in a reporter.&#xD;&#xD;Evaluates its first input.  If that expression successfully reports a value, this block reports that value.  If the expression causes a Snap! error,&#xD;then the final input slot is evaluated with the text of what would have&#xD;been the error message in variable ERROR.  SAFELY TRY then reports the value of that final expression.&#xD;&#xD;Sometimes you&apos;ll want to throw an error in the final expression.  You&#xD;can put an ERROR block inside a CALL block to do that.</comment><header></header><code></code><translations>ca:prova de forma segura reportant _ i si _ reportant _&#xD;</translations><inputs><input type="%anyUE"></input><input type="%upvar"></input><input type="%anyUE"></input></inputs><script><block s="doDeclareVariables"><list><l>value</l></list></block><custom-block s="safely try %cs then if %upvar %cs"><script><block s="doSetVar"><l>value</l><block s="evaluate"><block var="this"/><list></list></block></block></script><l>err</l><script><block s="doSetVar"><l>error</l><block var="err"/></block><block s="doSetVar"><l>value</l><block s="evaluate"><block var="that"/><list></list></block></block></script></custom-block><block s="doReport"><block var="value"/></block></script></block-definition></blocks><stage name="Stage" width="480" height="360" costume="0" color="255,255,255,1" tempo="60" threadsafe="false" penlog="false" volume="100" pan="0" lines="round" ternary="false" hyperops="true" codify="false" inheritance="true" sublistIDs="false" id="56"><pentrails>data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAeAAAAFoCAYAAACPNyggAAAAAXNSR0IArs4c6QAADoVJREFUeF7t1cEJAAAIxDDdf2m3sJ+4wEEQuuMIECBAgACBd4F9XzRIgAABAgQIjAB7AgIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmC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QIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECByxcQFpoRMBzwAAAABJRU5ErkJggg==</pentrails><costumes><list struct="atomic" id="57"></list></costumes><sounds><list struct="atomic" id="58"></list></sounds><variables></variables><blocks></blocks><scripts></scripts><sprites select="1"><sprite name="Sprite" idx="1" x="0" y="0" heading="90" scale="1" volume="100" pan="0" rotation="1" draggable="true" costume="0" color="80,80,80,1" pen="tip" id="63"><costumes><list struct="atomic" id="64"></list></costumes><sounds><list struct="atomic" id="65"></list></sounds><blocks></blocks><variables></variables><scripts><script x="14.000000000000398" y="11.500000000000071"><custom-block s="safely try %cs then if %upvar %cs"><script></script><l>error</l><script></script><comment w="264" collapsed="false">Input: Block of code&#xD;Output: Varies&#xD;If the first script succeeds, nothing else happens. Otherwise (something that would otherwise result in a red halo around the block), the second script is run, with the text of the error message that would have been shown in the variable ERROR.&#xD;Example 1:&#xD;If a script is expecting a list, but getting a text, the block take the error message and execute the second script. For instance, the sprite says, &quot;expecting a list but getting a text&quot;.</comment></custom-block></script><script x="398.99999999999943" y="10.000000000000014"><custom-block s="safely try %cs then if %upvar %cs"><script><block s="doReport"><block s="reportListItem"><l>1</l><block s="reportLetter"><l>1</l><l>world</l></block></block></block></script><l>error</l><script><block s="bubble"><block var="error"/></block></script></custom-block></script><script x="13.666666666667368" y="185.16666666666623"><custom-block s="error %txt"><l></l><comment w="268.6666666666667" collapsed="false">Input: Numbers, strings, scripts, lists and other data types&#xD;Output: An error message&#xD;This block throw an error by making a red halo appear around the script that runs it, with the input text shown in a speech balloon next to the script, just like any Snap! error.&#xD;Example 1:&#xD;If a script evaluates to w, and the script is the input of the error block, the output will be an error text with the result of input script. </comment></custom-block></script><script x="371.99999999999943" y="189.99999999999983"><custom-block s="safely try %cs then if %upvar %cs"><script><block s="doReport"><block s="reportListItem"><l>1</l><block s="reportLetter"><l>1</l><l>world</l></block></block></block></script><l>error</l><script><custom-block s="error %txt"><block var="error"/></custom-block></script></custom-block></script><script x="371.99999999999943" y="316.00000000000045"><custom-block s="error %txt"><block s="reportLetter"><l>1</l><l>world</l></block></custom-block></script><script x="10.000000000000057" y="347.1666666666672"><custom-block s="safely try reporting %anyUE then if %upvar report %anyUE"><l></l><l>error</l><l></l><comment w="271.66666666666634" collapsed="false">Input: Block of code&#xD;Output: String&#xD;If fisrt expression successfully reports a value, that value is reported. Otherwise the final input slot is evaluated with the text of what would have been the error message in variable ERROR. The value of that final expression is returned.&#xD;Example 1:&#xD;If the safely try block is correct, the output will be the output of the first-input, otherwise the output is the input of the last block.</comment></custom-block></script><script x="586.3333333333328" y="351.1666666666672"><custom-block s="safely try reporting %anyUE then if %upvar report %anyUE"><block s="reportListItem"><l>1</l><block s="reportLetter"><l>1</l><l>world</l></block></block><l>error</l><l>NOO!</l></custom-block></script><script x="584.6666666666663" y="400.50000000000057"><custom-block s="safely try reporting %anyUE then if %upvar report %anyUE"><block s="reportLetter"><l>1</l><l>world</l></block><l>error</l><l>NOO!</l></custom-block></script></scripts></sprite></sprites></stage><variables></variables></scene></scenes></project><media name="Library: Catch Errors" app="Snap! 9.0, https://snap.berkeley.edu" version="2"></media></snapdata>