Minor cleanup before release.
This commit is contained in:
@@ -4,11 +4,12 @@ Catch Exceptions
|
||||
{{#include ../links.md}}
|
||||
|
||||
|
||||
When an [exception] is thrown via a `throw` statement, evaluation of the script halts
|
||||
When an [exception] is thrown via a [`throw`] statement, evaluation of the script halts
|
||||
and the [`Engine`] returns with `Err(Box<EvalAltResult::ErrorRuntime>)` containing the
|
||||
exception value that has been thrown.
|
||||
|
||||
It is possible, via the `try` ... `catch` statement, to _catch_ exceptions.
|
||||
It is possible, via the `try` ... `catch` statement, to _catch_ exceptions, optionally
|
||||
with an _error variable_.
|
||||
|
||||
```rust
|
||||
// Catch an exception and capturing its value
|
||||
@@ -26,7 +27,7 @@ try
|
||||
{
|
||||
print(42/0); // deliberate divide-by-zero exception
|
||||
}
|
||||
catch // no catch variable - exception value is discarded
|
||||
catch // no error variable - exception value is discarded
|
||||
{
|
||||
print("Ouch!");
|
||||
}
|
||||
@@ -50,7 +51,7 @@ Re-Throw Exception
|
||||
------------------
|
||||
|
||||
Like the `try` ... `catch` syntax in most languages, it is possible to _re-throw_
|
||||
an exception within the `catch` block simply by another `throw` statement without
|
||||
an exception within the `catch` block simply by another [`throw`] statement without
|
||||
a value.
|
||||
|
||||
|
||||
@@ -76,20 +77,23 @@ Catchable Exceptions
|
||||
|
||||
Many script-oriented exceptions can be caught via `try` ... `catch`:
|
||||
|
||||
* Runtime error thrown by a `throw` statement
|
||||
* Arithmetic error
|
||||
* Variable not found
|
||||
* [Function] not found
|
||||
* [Module] not found
|
||||
* Unbound [`this`]
|
||||
* Data type mismatch
|
||||
* [Array]/[string] indexing out-of-bounds
|
||||
* Indexing with an inappropriate type
|
||||
* `for` statement without an iterator
|
||||
* Error in an `in` expression
|
||||
* Data race detected
|
||||
* Assignment to a calculated value/constant value
|
||||
* Dot expression error
|
||||
| Error type | Error value |
|
||||
| --------------------------------------------- | :------------------------: |
|
||||
| Runtime error thrown by a [`throw`] statement | value in `throw` statement |
|
||||
| Other runtime error | error message [string] |
|
||||
| Arithmetic error | error message [string] |
|
||||
| Variable not found | error message [string] |
|
||||
| [Function] not found | error message [string] |
|
||||
| [Module] not found | error message [string] |
|
||||
| Unbound [`this`] | error message [string] |
|
||||
| Data type mismatch | error message [string] |
|
||||
| Assignment to a calculated/constant value | error message [string] |
|
||||
| [Array]/[string] indexing out-of-bounds | error message [string] |
|
||||
| Indexing with an inappropriate data type | error message [string] |
|
||||
| Error in a dot expression | error message [string] |
|
||||
| `for` statement without an iterator | error message [string] |
|
||||
| Error in an `in` expression | error message [string] |
|
||||
| Data race detected | error message [string] |
|
||||
|
||||
|
||||
Non-Catchable Exceptions
|
||||
@@ -99,6 +103,6 @@ Some exceptions _cannot_ be caught:
|
||||
|
||||
* Syntax error during parsing
|
||||
* System error - e.g. script file not found
|
||||
* Script evaluation over [limits]({{rootUrl}}/safety/index.md)
|
||||
* [Stack overflow][maximum call stack depth]
|
||||
* Script evaluation metrics over [safety limits]({{rootUrl}}/safety/index.md)
|
||||
* Function calls nesting exceeding [maximum call stack depth]
|
||||
* Script evaluation manually terminated
|
||||
|
Reference in New Issue
Block a user