Skip to content

fix error handling, type safety, and several bugs - #614

Open
YashejShah wants to merge 4 commits into
razorpay:masterfrom
YashejShah:fix/error-handling-and-type-safety
Open

YashejShah wants to merge 4 commits into
razorpay:masterfrom
YashejShah:fix/error-handling-and-type-safety

Conversation

@YashejShah

Copy link
Copy Markdown

summary

spent some time going through the codebase and found a bunch of issues worth fixing — from actual bugs to type safety gaps.

highlights

error handling

  • errorBoundary was casting Error objects to string, turning every error message into [object Object]. fixed to properly extract message and preserve stack traces
  • added res.ok checks on all geo module fetch calls — 404/500 responses were being parsed as JSON and silently failing

phone number module

  • matchesEntirely was constructing a new RegExp on every call with complex country patterns. added a cache to avoid redundant compilation
  • cleanPhoneNumber had a nonsensical (?!A)\+ regex — simplified to actually do what it's supposed to

currency

  • convertToMinorUnit was using floating point multiplication (amount * multiplier) which is unreliable for currency math. switched to Math.round
  • formatNumber was accepting hex strings and Infinity as valid numbers

react provider

  • updateI18nState had a stale closure bug — global state was being set with old values instead of the updated ones
  • useI18nContext error check never fired because the default context value was {} (truthy). fixed by using undefined as default

types

  • removed several unnecessary as any casts
  • fixed direction type that was 'ltr' | 'rtl' | string (equivalent to just string)
  • fixed rawParts.value from unknown to string

dates

  • day validation regex was accepting values like 99 — added proper range check
  • relative time was using exactly 30 days/month and 365 days/year

all changes are backwards compatible.

@changeset-bot

changeset-bot Bot commented Mar 11, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: c39da3d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

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.

1 participant