Error objects don't log well
Closed this issue · 2 comments
A few adaptors have a pattern where they create an Error object and throw it.
This isn't itself unreasonable!
But when serializing that error for the console or the final state, we lose all the detail.
If I console.log this error, I do see some of the properties:
Here you can see my custom status
code.
The stack trace right now is not useful - although will be once we handle source mapping
The thing we report in the CLI isn't so good:
And the thing we write to state is useless:
No surprises here, it's just getting a better understanding of how different errors are reported out of the runtime
Probably the code that generates that error object on state should serialize all the keys of the error object into JSON.
And the Runtime log at the end, which says check state for details, should pretty-print the keys nicely too
Maybe related? Posting here
In okd, using http helpers without much wrapping, I see this in my logs:
Ok, it reported a 404, but there's more data in the error response.
State doesn't show anything useful:
{
"data": {},
"errors": {
"job-1": {
"type": "AdaptorError",
"stepId": "job-1",
"message": "GET to https://sandbox.getodk.cloud/v1/projects/69 returned 404: Not Found",
"error": {
"source": "runtime",
"type": "AdaptorError",
"name": "AdaptorError",
"severity": "fail",
"message": "GET to https://sandbox.getodk.cloud/v1/projects/69 returned 404: Not Found"
}
}
}
}
But the actual Error object that was reported is super rich! This should serialize better!