TRY/CATCH

If using code that potentially can fail from time to time it is possible to use a Try Catch-statement and
programmatically handle the error as opposed to having the application error out.

Syntax for Try/Catch statement:

Try 
// Commands to try to execute
End Try
Catch
// Commands to execute when an error occurs
End Catch

 

Example:

TRY // Try the commands between this line and End Try 
IMPORT [budget]=excelfile.{select * from [c:\budget\custombudgetfile.xlsx]} // Import budget from file
that may be edited by people in the organization
END TRY
CATCH // If the try fails the commands in this catch block will be executed
PRINT 'An error occurred loading the custom budget file - will default to loading the audited budget file'
IMPORT [budget]=excelfile.{select * from [c:\budget\auditedbudgetfile.xlsx]} // Load the budget file that we know
END CATCH
Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.