Menu

keywords-try

Will Pittenger

Marks the start of a try/catch/finally exception handling block. Must be combined with catch and/or finally. For more on exception handing, see [Exceptions]. For more on the exception related keywords see throws, throw, catch, and finally.

try with catch

:::text
\try\
  ' Some code that might throw one or more exceptions
\catch\ ExceptionTypeName identifier
  ' Handle the exception
' Repeat catch clause as needed

try with catch and finally

:::text
\try\
  ' Some code that might throw one or more exceptions
\catch\ ExceptionTypeName identifier
  ' Handle the exception
' Repeat catch clause as needed
\finally\
  ' clean up 

try with finally, but no catch

You can use a try block that lacks a catch clause. However, since it doesn't catch anything, be sure to consider a throws clause on the procedure.

:::text
\try\
  ' Some code that might throw one or more exceptions
\finally\
  ' clean up

Related

Wiki: Appendices-Deprecated keywords, operators, and delimiters
Wiki: Exceptions
Wiki: Keywords
Wiki: keywords-catch
Wiki: keywords-finally
Wiki: keywords-throw
Wiki: keywords-throws

MongoDB Logo MongoDB