Skip to content

fix(paper-by-id): return 404 when the paper does not exist - #561

Open
Dx-Alz-xD wants to merge 1 commit into
CodeChefVIT:stagingfrom
Dx-Alz-xD:krish/paper-by-id-not-found
Open

Dx-Alz-xD wants to merge 1 commit into
CodeChefVIT:stagingfrom
Dx-Alz-xD:krish/paper-by-id-not-found

Conversation

@Dx-Alz-xD

Copy link
Copy Markdown

📌 Purpose

a valid ObjectId with no matching paper returned a 500, bcs getPaperById threw a plain Error, the paper page also never redirected for missing papers it checks for 400/404 axios errors, but fetchPaperID rethrew everything as a plain Error.


Corresponding issue: closes #554


🖼️ Showcase

  • GET /api/paper-by-id/000000000000000000000000: 500 → 404 {"message":"paper not found"}
  • GET /paper/000000000000000000000000: error text → 307 redirect to /
  • An existing paper still returns 200

🔧 Changes


➕ Additional Notes

  • Other errors behave as before

getPaperById threw a plain error, so a valid id with no paper came back
as a 500. throw a CustomError with 404 and use customErrorHandler in the
route, and let fetchPaperID pass 400 and 404 through so the paper page
redirects home as it intends to

This branch has not been deployed

No deployments
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.

/api/paper-by-id returns 500 instead of 404 for a paper that doesn't exist

1 participant