Try

Syntax:
Try
// Try operators
Except
// Exception operators
[Raise;]
// Exception operators
EndTry;

Parameters:
// Try operators
An executable operator or a sequence of executable operators.

Except
Operators following the Except keyword are executed if a runtime error occurs during the execution of the operator sequence.

// Exception operators
An executable operator or a sequence of operators that handle the exception.

Raise
The operator that generates an exception in cases when, even though the exception is handled by the exception operators, it is necessary to stop the module execution and generate a runtime error. This operator is valid only inside the Except - EndTry keyword pair.

The execution of this operator stops the execution of the exception operator sequence and starts the search for a higher-level exception handler (when the Try operators are nested). If such exception handler is found, the control is passed to it. Otherwise the exception is handled by the operating system, a message about the original error is issued, and the module execution is stopped.

EndTry
A keyword that ends the exception handling block.

Description:
The Try operator controls the script execution based on errors (exceptions) that arise in the process of the module execution, and defines how these exceptions are handled. Errors (exceptions) originate from module runtime errors. User-defined exceptions are not supported.

If a runtime error occurs during the execution of an operator sequence, the execution of the operator that caused the error is stopped, and the control is passed to the first operator from the exception handling operator sequence. The control is passed even if the error is caused by an operator within a procedure or function called from a Try operator. If an error occurs in a procedure or function, the procedure or function is terminated and its local variables are destroyed. This is true for any nesting level of a procedure or function call. Once the exception operator sequence is executed, the control is passed to the operator following the EndTry keyword. If the try operator sequence is executed without errors, the exception operator sequence is skipped, and the control is also passed to the operator following the EndTry keyword.

The Try - Except - EndTry clauses can be nested. If an exception is raised, the control is passed to the handler in whose try operator the error occurred. If a Raise operator is called in the exception operator sequence of this handler, the control is passed to the exception handler one level higher, and so on. If there is no exception handler on a higher level, the exception is handled by the system and the module is terminated.

See also: 

                  ErrorInfo() method

                  ErrorDescription() method


    

1C:Enterprise Developer's Community