-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Official client error class does not extend `Error` so no stack trace :( See Airtable/airtable.js#294
- Loading branch information
Vladimir Ubogovich
committed
Jan 27, 2022
1 parent
3ec4b07
commit 39cee68
Showing
6 changed files
with
59 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@qualifyze/airtable": major | ||
--- | ||
|
||
[BREAKING CHANGE] Introduce `AirtableError` extending `Error` to bring the stack trace very useful for debugging. | ||
The consumers should check their code for usage of `Airtable.Error` from the official client and replace it with the one from this library. |
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,20 @@ | ||
import type { Error as OfficialClientError } from "airtable"; | ||
|
||
// Use a custom error to bring the proper stack trace | ||
export class AirtableError extends Error { | ||
constructor( | ||
public error: string, | ||
message: string, | ||
public statusCode: number | ||
) { | ||
super(message); | ||
} | ||
|
||
static fromOfficialClientError({ | ||
error, | ||
message, | ||
statusCode, | ||
}: OfficialClientError) { | ||
return new AirtableError(error, message, statusCode); | ||
} | ||
} |
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
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