$error
Used in the $catch
block to return the BDScript 2 error information.
Can only be used in BDScript 2.
Syntax
$error[Type]
Parameters
Type
(Type: Enum || Flag: Required)
: What type of error data to return.
Error Type
Name | Description | Example |
---|---|---|
command | Returns the name of the function that returned the error. | $sum |
message | Returns the error message that was received. | expected integer in position 2, got ‘a’ |
source | Returns the content of the line where the error occurred. | $sum[2;a] |
row | Returns the number of the row in the code where the error occurred. | 2 |
column | Returns the number of the column in the code where the error occurred. | 10 |
The type input must only be written in lowercase letters.
❌ Not correct:
$error[MEsSage]
✅ Correct:
$error[message]
Example
$nomention
$try
$description[Hello developer!;]
$catch
❌ An error has occurred!
Function: $error[command]
Error: $error[message]
$endtry
Function: $description
Error: expected valid value in position 2, got empty value
How $description[]
, $try
, $endtry
and $catch
works?
For more information, read the Error Handling guide.