Skip to content

feat: gracefully handle backend errors - #176

Merged
HermanPlay merged 3 commits into
masterfrom
feat/graceful-error-handling
Aug 16, 2026
Merged

HermanPlay merged 3 commits into
masterfrom
feat/graceful-error-handling

Conversation

@HermanPlay

Copy link
Copy Markdown
Member

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

  • Resolver (src/lib/errors/backend-error.ts): maps all 68 backend ERR_* codes to localized messages; resolveErrorMessage() resolves by code → HTTP status group (401/403/404/409/400/408/502/503/504/5xx) → network failure → fallback.
  • Helpers: showApiError(err, fallback?) toast helper; ApiError.getLocalizedMessage().
  • i18n: backend_error_* keys for every code + group fallbacks, in en.json and pl.json.
  • Services: all 11 API services now return localized error strings (replacing raw backend English from getApiMessage()).
  • ErrorCard: resolves ApiError → localized message (covers all load-error cards centrally).
  • Components: every form/action catch block migrated to showApiError(error, <existing fallback key>) (30 files). Pure client-side guard toasts unchanged.

Verification

  • pnpm run check: 0 errors
  • prettier clean on new TS; eslint clean on new/changed code (remaining eslint errors are pre-existing baseline issues in untouched lines)
  • all 68 backend codes confirmed mapped (zero unmapped)
  • deployed locally; login/conflict/404/network error paths show localized messages

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
@HermanPlay
HermanPlay merged commit 82d38b0 into master Aug 16, 2026
1 check passed
@HermanPlay
HermanPlay deleted the feat/graceful-error-handling branch August 16, 2026 21:12
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.

Gracefully handle errors backend returns

1 participant