feat(api): add error_type field and HTTP status codes for errors#19
Merged
guanbinrui merged 1 commit intomasterfrom Feb 28, 2026
Merged
feat(api): add error_type field and HTTP status codes for errors#19guanbinrui merged 1 commit intomasterfrom
guanbinrui merged 1 commit intomasterfrom
Conversation
- Add optional error_type parameter to respJsonError template for reliable
client-side error detection
- Add httpCode parameter to return proper HTTP status codes
- Use HTTP 404 for not_found errors (tweet/user not found)
- Use "not_found" error_type for tweet and user not found errors
This allows clients to:
1. Check error_type === 'not_found' instead of parsing error messages
2. Rely on HTTP status codes for proper REST semantics
Example error response:
HTTP/1.1 404 Not Found
{
"code": -1,
"error": "Tweet not found",
"error_type": "not_found"
}
5b0830a to
35b16ef
Compare
guanbinrui
approved these changes
Feb 28, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
error_typeparameter torespJsonErrortemplate for reliable client-side error detectionhttpCodeparameter to return proper HTTP status codesnot_founderrors (tweet/user not found)Changes
Before
After
Benefits
Clients can now detect not-found errors by:
response.status === 404)response.error_type === 'not_found')This is more reliable than parsing error message strings.
Related