feat: gracefully handle backend errors - #176
Merged
Merged
Conversation
Map all backend error codes to localized messages and surface them consistently across the app: - add backend-error resolver mapping every ERR_* code to i18n messages (en/pl) with HTTP status-group and network fallbacks - showApiError toast helper; ApiError.getLocalizedMessage() - services return localized error strings instead of raw backend text - ErrorCard resolves ApiError messages centrally - migrate all form/action catch blocks to showApiError
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
Gracefully handles every error the backend can return, using its
ERR_*error codes (which the backend explicitly documents as "for frontend internationalization") and HTTP status codes. Closes #68.Changes
src/lib/errors/backend-error.ts): maps all 68 backendERR_*codes to localized messages;resolveErrorMessage()resolves by code → HTTP status group (401/403/404/409/400/408/502/503/504/5xx) → network failure → fallback.showApiError(err, fallback?)toast helper;ApiError.getLocalizedMessage().backend_error_*keys for every code + group fallbacks, inen.jsonandpl.json.getApiMessage()).ApiError→ localized message (covers all load-error cards centrally).showApiError(error, <existing fallback key>)(30 files). Pure client-side guard toasts unchanged.Verification
pnpm run check: 0 errors