supabase / postgrest-js

Isomorphic JavaScript client for PostgREST.
https://supabase.com
MIT License
962 stars 128 forks source link

Ensure thrown errors have a stack trace #502

Closed meyer9 closed 5 months ago

meyer9 commented 7 months ago

What kind of change does this PR introduce?

Feature: thrown errors now return a stack trace:

$ yarn test:run
  console.log
    PostgrestError: relation "public.does_not_exist" does not exist
        at /Users/meyer9/development/postgrest-js/src/PostgrestBuilder.ts:160:17
        at processTicksAndRejections (node:internal/process/task_queues:95:5)
        at Object.<anonymous> (/Users/meyer9/development/postgrest-js/test/basic.ts:10:17) {
      code: '42P01',
      details: null,
      hint: null
    }

      at Object.<anonymous> (test/basic.ts:12:13)

 PASS  test/index.test.ts
  ✓ returned error should include stack (46 ms)

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        0.587 s, estimated 1 s
Ran all test suites.

What is the current behavior?

Errors are currently plain objects: https://github.com/supabase/postgrest-js/issues/501

What is the new behavior?

Thrown errors will now throw a PostgrestError with a message and the details. Errors should serialize to the same value by default.

github-actions[bot] commented 5 months ago

:tada: This PR is included in version 1.9.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket: