Skip to content

Commit

Permalink
fix: use class PostgrestError instead of type PostgrestError (#562)
Browse files Browse the repository at this point in the history
  • Loading branch information
hammerlscs authored Oct 19, 2024
1 parent 69afff9 commit e45a2c7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
11 changes: 7 additions & 4 deletions src/PostgrestError.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import type { PostgrestError as IPostgrestError } from './types'

export default class PostgrestError extends Error implements IPostgrestError {
/**
* Error format
*
* {@link https://postgrest.org/en/stable/api.html?highlight=options#errors-and-http-status-codes}
*/
export default class PostgrestError extends Error {
details: string
hint: string
code: string

constructor(context: IPostgrestError) {
constructor(context: { message: string; details: string; hint: string; code: string }) {
super(context.message)
this.name = 'PostgrestError'
this.details = context.details
Expand Down
14 changes: 2 additions & 12 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
export type Fetch = typeof fetch
import PostgrestError from './PostgrestError'

/**
* Error format
*
* {@link https://postgrest.org/en/stable/api.html?highlight=options#errors-and-http-status-codes}
*/
export type PostgrestError = {
message: string
details: string
hint: string
code: string
}
export type Fetch = typeof fetch

/**
* Response format
Expand Down

0 comments on commit e45a2c7

Please sign in to comment.