I swear, this is getting in my nerves and I don’t know how to fix this error:
“[SAFE MODE] Exception caught and saved to data.ERROR: System.ArgumentException: The provided json is not a valid object or array”
The response code is null, why is the stacker’s status changing to ERROR when an array from a parse block isn’t found instead of just ignoring the fact it wasn’t found and continue with the same SUCCESS status?
How can I stop this from happening?
Checked it, does not stop the error from happening. Did some digging using ChatAI and this is what it suggested:
" Certainly! Here are a few examples of how you could handle the case where the parsed array is not found:
Use a try-catch block to handle the exception:
try
{
JArray arr = data["parsedArray"];
// Do something with the array
}
catch (Exception ex)
{
// Handle the exception, e.g. by logging it or providing a default value
}
Check if the token exists before accessing it:
if (data["parsedArray"] != null && data["parsedArray"].Type == JTokenType.Array)
{
JArray arr = data["parsedArray"];
// Do something with the array
}
else
{
// Handle the case where the token is not found or is not an array
}
Provide a default value if the token is not found:
JArray arr = data["parsedArray"] as JArray ?? new JArray();
// Do something with the array (which will be an empty array if the token is not found)
Note that the best approach depends on the specific requirements and context of your application, so it’s important to choose the method that makes the most sense for your use case.
However, I think this is an extra addition to something that wasn’t needed in OB1.