When a conditional statement is used inside the Try block to determine whether-or-not an exception is thrown, and that condition causes an exception to be thrown, the resulting string from the caught exception is (nil) in the Exception Handler.
To Reproduce
Enter the following snippet into a fresh E2 file (overwriting the boilerplate code in the process)...
@name exception_handling_test
@strict
if (first())
{
Set Throw_an_exception to any value other than zero to trigger an exception, right off the bat.
let Throw_an_exception = 1
try
{
if (Throw_an_exception != 0)
{
error("An exception was throw, right off the bat.")
}
}
catch(Exception:string)
{
# The Exception string is not actually printed, because it technically contains nothing.
print("Exception caught:")
print(Exception)
#]#
#[You MAY comment out the print statements above, to test the error ping here.
# NOTE: The E2 will shut down, and an obscure error notification regarding string handling will show instead.
print("Exception caught: " + Exception)
#]#
}
}
2. Spawn the E2 chip somewhere.
3. Chat print will simply read `Exception caught:` with no text present where `An exception was thrown, right off the bat.` should be.
Alternatively, you can combine the two `print()` statements to look like `print("Exception caught: " + Exception)`, and the E2 will shut down with an obscure error (see attached screenshot).
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
![Screenshot from 2024-06-05 20-07-59](https://github.com/wiremod/wire/assets/48301275/6efc79c6-2ef4-472e-b434-1349c4fc9ea9)
This error comes up when `Exception` is combined with any string constant.
Describe the bug
When a conditional statement is used inside the Try block to determine whether-or-not an exception is thrown, and that condition causes an exception to be thrown, the resulting string from the caught exception is
(nil)
in the Exception Handler.To Reproduce
if (first()) {
Set Throw_an_exception to any value other than zero to trigger an exception, right off the bat.
}