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

refactor: introduce ErrorWithKey (locales keys as error code) #621

Merged
merged 2 commits into from
Sep 24, 2024

Conversation

sidvishnoi
Copy link
Member

@sidvishnoi sidvishnoi commented Sep 23, 2024

Context

Closes #620
Extracted from #619 (check out usage in addPublicKeyToWallet + its handler; also in ConnectWalletForm validation handler)

Changes proposed in this pull request

  • Introduces following helpers:
    • ErrorWithKey (extends Error; useful for throwing with stack-trace)
    • errorWithKey (lighter version of ErrorWithKey; useful when stack-trace not needed)
    • isErrorWithKey (checks if an object is ErrorWithKey or response of errorWithKey)
  • Extends ErrorResponse and failure to have optional {error?: ErrorWithKeyLike}
  • Extends translation/localization helpers (t, useTranslation) to allow converting ErrorWithKeyLike to string via _locales/[lang]/message.json

@github-actions github-actions bot added area: background Improvements or additions to extension background script area: popup Improvements or additions to extension popup labels Sep 23, 2024
Copy link

github-actions bot commented Sep 23, 2024

Extension builds preview

Name Link
Latest commit 78bb92b
Latest job logs Run #11011307580
BadgeDownload
BadgeDownload

@sidvishnoi sidvishnoi changed the title refactor: introduce ErrorWithKey (translation keys as error code) refactor: introduce ErrorWithKey (locales keys as error code) Sep 23, 2024
fix: limit error codes to ErrorKey (instead of all TranslationKeys)

nit: rename IErrorWithKey to ErrorWithKeyLike
@sidvishnoi sidvishnoi merged commit 1447173 into main Sep 24, 2024
9 checks passed
@sidvishnoi sidvishnoi deleted the error-with-key branch September 24, 2024 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: background Improvements or additions to extension background script area: popup Improvements or additions to extension popup
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add concept of error codes
2 participants