Closed meyer9 closed 5 months ago
Is there any chance I can get an update on this issue? It would be extremely useful to have a stack trace on errors thrown by postgrest-js for observability. Let me know if I can do anything to make it easier for maintainers!
@soedirgo @laurenceisla Please check this out. This is a huge issue for observability with a super simple fix. We currently can't trace DB errors down to a specific line. I have a PR up with tests.
Bug report
Describe the bug
Errors returned do not include a stack trace because they are throwing a plain object instead of an
Error
. This makes it annoying to track down the root cause of an error because there's no way to tell where it was thrown from.To Reproduce
Write a postgrest-js query that returns an error. Notice that
error.stack
is undefined anderror instanceof Error
is false.Expected behavior
I expect stack to be set on the result. I think it might be good to return a
PostgrestError
that extendsError
with the error details, but also just throwing a plainError
is probably fine too!