I have a try/catch in my server action where I want to show the $_ERROR.
This variable seems to not populate properly anymore. It doesn't show the value when I try to log $_ERROR.
Reproduce
Create a try/catch
Put a query in the try, don't set up any settings inside query so it'll fail
Add a response step in teh catch where you add the $_ERROR to the 'text' property
Should look like this:
The problem is that in JavaScript an Error object is not serializable in JSON and is ignored. I added an extra replacer function for the JSON output that converts the Error object to a string. Easiest way to output an Error is by using the toString() formatter. I will investigate for some other solutions.
As far as I'm aware the $_ERROR variable set by Wappler can be a javascript object, OR a javascript error object.
If it's an error object, the following happens
If I try to set a value like
error_raw = {{$_ERROR}}`
I get
{
"status": "500",
"message": "A server error occurred, to see the error enable the DEBUG flag."
}
Which is really not desirable as this is now breaking the rest of the server action (even though this is already in a CATCH)... So just by setting a variable in the catch, the other thing won't run.
Visual:
Which is better as it doesn't break it... but the issue here is that depending on the type of error (normal object or javascript error object) I need a different formatter.
Plus we need to add formatters to all the places where we're just using the $_ERROR as is.
It would be a much better solution if the logic to either stirngify or .toString() is done where you are currently setting the $_ERROR variable in the first place
I swear that this was never an issue before, something must have changed - maybe you can find that change and revert it...