Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support expired and not-found ref API errors #327

Merged
merged 3 commits into from
Oct 6, 2023

Conversation

angeloashmore
Copy link
Member

@angeloashmore angeloashmore commented Oct 2, 2023

Types of changes

  • Chore (a non-breaking change which is related to package maintenance)
  • Bug fix (a non-breaking change which fixes an issue)
  • New feature (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

This PR adds support for two new ref-related errors that may be returned by Rest API V2:

  • RefNotFoundError: Thrown when a query's ref does not exist.
  • RefExpiredError: Thrown when a query's ref is expired (generally older than 5 minutes if it is not the master ref or a release).

This is a non-breaking change since the errors were previously thrown as ForbiddenErrors. The new error types extend from ForbiddenError and will continue to work with instanceof ForbiddenError.

The new errors will extend from PrismicError in a future major version for better semantics.

Checklist:

  • My change requires an update to the official documentation.
  • All TSDoc comments are up-to-date and new ones have been added where necessary.
  • All new and existing tests are passing.

🫎

Copy link
Member

@lihbr lihbr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small suggestion so we can release that as a minor, but look good to me otherwise :)

src/errors/RefNotFoundError.ts Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Oct 3, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (fb555fd) 99.97% compared to head (a34d2d2) 99.97%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #327   +/-   ##
=======================================
  Coverage   99.97%   99.97%           
=======================================
  Files          57       59    +2     
  Lines        6794     6843   +49     
  Branches      374      376    +2     
=======================================
+ Hits         6792     6841   +49     
  Misses          2        2           
Files Coverage Δ
src/createClient.ts 100.00% <100.00%> (ø)
src/errors/ForbiddenError.ts 100.00% <100.00%> (ø)
src/errors/NotFoundError.ts 100.00% <100.00%> (ø)
src/errors/ParsingError.ts 100.00% <100.00%> (ø)
src/errors/RefExpiredError.ts 100.00% <100.00%> (ø)
src/errors/RefNotFoundError.ts 100.00% <100.00%> (ø)
src/index.ts 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@angeloashmore angeloashmore merged commit 26d5b0f into master Oct 6, 2023
12 checks passed
@angeloashmore angeloashmore deleted the aa/ref-errors branch October 6, 2023 00:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants