-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support expired and not-found ref API errors (#327)
* feat: support expired and not-found ref API errors * fix: extend `RefNotFoundError` and `RefExpiredError` from `ForbiddenError` for backwards compatibility
- Loading branch information
1 parent
fb555fd
commit 26d5b0f
Showing
8 changed files
with
113 additions
and
10 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
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import { PrismicError } from "./PrismicError"; | ||
|
||
export class NotFoundError extends PrismicError<undefined> {} | ||
export class NotFoundError< | ||
TResponse = undefined, | ||
> extends PrismicError<TResponse> {} |
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,14 @@ | ||
import { ForbiddenError } from "./ForbiddenError"; | ||
|
||
type RefExpiredErrorAPIResponse = { | ||
type: "api_validation_error"; | ||
message: string; | ||
}; | ||
|
||
// This error extends `ForbiddenError` for backwards compatibility. Before the | ||
// API started returning 410 for expired refs, it returnd 403, which threw a | ||
// `ForbiddenError`. | ||
// TODO: Extend this error from `PrismicError` in v8. | ||
export class RefExpiredError< | ||
TResponse = RefExpiredErrorAPIResponse, | ||
> extends ForbiddenError<TResponse> {} |
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,14 @@ | ||
import { ForbiddenError } from "./ForbiddenError"; | ||
|
||
type RefNotFoundErrorAPIResponse = { | ||
type: "api_notfound_error"; | ||
message: string; | ||
}; | ||
|
||
// This error extends `ForbiddenError` for backwards compatibility. Before the | ||
// API started returning 404 for not found refs, it returnd 403, which threw a | ||
// `ForbiddenError`. | ||
// TODO: Extend this error from `PrismicError` in v8. | ||
export class RefNotFoundError< | ||
TResponse = RefNotFoundErrorAPIResponse, | ||
> extends ForbiddenError<TResponse> {} |
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