Skip to content

Commit e45a2c7

Browse files
author
hammerlscs
authored
fix: use class PostgrestError instead of type PostgrestError (#562)
1 parent 69afff9 commit e45a2c7

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

src/PostgrestError.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
import type { PostgrestError as IPostgrestError } from './types'
2-
3-
export default class PostgrestError extends Error implements IPostgrestError {
1+
/**
2+
* Error format
3+
*
4+
* {@link https://postgrest.org/en/stable/api.html?highlight=options#errors-and-http-status-codes}
5+
*/
6+
export default class PostgrestError extends Error {
47
details: string
58
hint: string
69
code: string
710

8-
constructor(context: IPostgrestError) {
11+
constructor(context: { message: string; details: string; hint: string; code: string }) {
912
super(context.message)
1013
this.name = 'PostgrestError'
1114
this.details = context.details

src/types.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
1-
export type Fetch = typeof fetch
1+
import PostgrestError from './PostgrestError'
22

3-
/**
4-
* Error format
5-
*
6-
* {@link https://postgrest.org/en/stable/api.html?highlight=options#errors-and-http-status-codes}
7-
*/
8-
export type PostgrestError = {
9-
message: string
10-
details: string
11-
hint: string
12-
code: string
13-
}
3+
export type Fetch = typeof fetch
144

155
/**
166
* Response format

0 commit comments

Comments
 (0)