-
Notifications
You must be signed in to change notification settings - Fork 308
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: do not require index sig on vars (#659)
- Loading branch information
1 parent
fff4731
commit 8f926b8
Showing
16 changed files
with
510 additions
and
493 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import type { GraphQLRequestContext, GraphQLResponse } from '../helpers/types.js' | ||
|
||
export class ClientError extends Error { | ||
public response: GraphQLResponse | ||
public request: GraphQLRequestContext | ||
|
||
constructor(response: GraphQLResponse, request: GraphQLRequestContext) { | ||
const message = `${ClientError.extractMessage(response)}: ${JSON.stringify({ | ||
response, | ||
request, | ||
})}` | ||
|
||
super(message) | ||
|
||
Object.setPrototypeOf(this, ClientError.prototype) | ||
|
||
this.response = response | ||
this.request = request | ||
|
||
// this is needed as Safari doesn't support .captureStackTrace | ||
if (typeof Error.captureStackTrace === `function`) { | ||
Error.captureStackTrace(this, ClientError) | ||
} | ||
} | ||
|
||
private static extractMessage(response: GraphQLResponse): string { | ||
return response.errors?.[0]?.message ?? `GraphQL Error (Code: ${response.status})` | ||
} | ||
} |
Oops, something went wrong.