$error

Used in the $catch block to return the BDScript 2 error information.

BDScript 2

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

NameDescriptionExample
commandReturns the name of the function that returned the error.$sum
messageReturns the error message that was received.expected integer in position 2, got ‘a’
sourceReturns the content of the line where the error occurred.$sum[2;a]
rowReturns the number of the row in the code where the error occurred.2
columnReturns the number of the column in the code where the error occurred.10

Syntax sensitivity

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
!example ❌ An error has occurred!
Function: $description
Error: expected valid value in position 2, got empty value

What is this?

How $description[], $try, $endtry and $catch works?

Read more

For more information, read the Error Handling guide.