Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

developer:scriptsamples:errorhandling [2015/09/14]
127.0.0.1 external edit
developer:scriptsamples:errorhandling [2016/01/20] (current)
sandy
Line 1: Line 1:
 ======Error Handling in RhinoScript====== ======Error Handling in RhinoScript======
 > **Developer:​** //​[[developer:​rhinoscript|RhinoScript]]//​ > **Developer:​** //​[[developer:​rhinoscript|RhinoScript]]//​
-> **Summary:​** //Describes the error handling semantics of VBScript.//+> **Summary:​** //Describes the error handling semantics of VBScript//
  
-=====Overview===== 
 There are two statements that affect error handling in VBScript: There are two statements that affect error handling in VBScript:
  
Line 13: Line 12:
 The meaning of the first statement is this: if you get an error, ignore it and resume execution on the next statement. As we'll see, there are some subtleties. The meaning of the first statement is this: if you get an error, ignore it and resume execution on the next statement. As we'll see, there are some subtleties.
  
-The second statement simply turns off "​Resume Next" mode if it is on. The odd syntax is because Visual Basic has an error handling mode which VBScript does not -- VB can branch to a labeled or numbered statement.+The second statement simply turns off "​Resume Next" mode if it is on. The odd syntax is because Visual Basic has an error handling mode which VBScript does notVB can branch to a labeled or numbered statement.
  
 =====Discussion===== =====Discussion=====
Line 45: Line 44:
    ​Global code end    ​Global code end
  
-When the error ocurred, Blah1 had already turned "​Resume Next" mode on. The next statement ​after the error raise is Print "Blah2 End" but that statement was never executed. This is because the error mode is on a per-procedure basis, not a global basis.+When the error occurred, Blah1 had already turned "​Resume Next" mode on. The next statement is Print "Blah2 End" but that statement was never executed. This is because the error mode is on a per-procedure basis, not a global basis.
  
 Also, remember that the "​Next"​ in "​Resume Next" mode is the next statement. Consider these two scripts: Also, remember that the "​Next"​ in "​Resume Next" mode is the next statement. Consider these two scripts:
Line 62: Line 61:
 They do not have the same semantics. If Foo.Bar raises an error, then the first script passes Empty to Blah. The second one never calls Blah at all if an error is raised, because it resumes to the next statement. They do not have the same semantics. If Foo.Bar raises an error, then the first script passes Empty to Blah. The second one never calls Blah at all if an error is raised, because it resumes to the next statement.
  
-You can get into similar trouble with other constructs. For example, these do have the same semantics:+You can get into similar trouble with other constructs. For example, these have the same semantics:
  
 <code vb> <code vb>
developer/scriptsamples/errorhandling.txt ยท Last modified: 2016/01/20 by sandy