Skip to content

[Bug] mobilePayments.ts bare catch block does not narrow error type before property access #796

Description

@RUKAYAT-CODER

Overview

mobilePayments.ts catches errors with catch (error: unknown) but immediately accesses properties like error.message without first checking if error is an Error instance. This causes a secondary TypeError at runtime.

Specifications

Features:

  • Add a type narrowing function toError(caught: unknown): Error that wraps non-Error values
  • Use it consistently in all catch blocks across mobilePayments.ts

Tasks:

  • Implement toError utility
  • Apply it in all catch blocks in the file
  • Run TypeScript strict mode to find remaining unsafe accesses

Impacted Files:

  • src/services/mobilePayments.ts
  • src/utils/toError.ts (new)

Acceptance Criteria

  • No unchecked error.message access in catch blocks
  • toError utility is exported and reusable across the codebase
  • TypeScript strict mode emits no errors in this file

Metadata

Metadata

Labels

Stellar WaveIssues in the Stellar wave programbugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions