Skip to content

fix: reject xero-node API failures as Error objects#812

Open
miachillgood wants to merge 1 commit into
XeroAPI:masterfrom
miachillgood:codex/reject-error-objects
Open

fix: reject xero-node API failures as Error objects#812
miachillgood wants to merge 1 commit into
XeroAPI:masterfrom
miachillgood:codex/reject-error-objects

Conversation

@miachillgood

Copy link
Copy Markdown

Summary

  • reject SDK promise failures as Error objects instead of JSON strings
  • keep the structured Xero response attached on the error object for downstream inspection
  • add regression coverage for the new ApiError.toError() path

Why

Issues #500 and #741 both point at the same behavior: API failures are surfaced as non-Error rejections, and in newer paths they can even become plain strings via JSON.stringify(...). That breaks standard promise/error handling flows and strips away normal Error behavior like name, message, and stack handling.

This change keeps the structured response payload, but wraps it in a real Error instance so callers can handle failures predictably.

Validation

  • npm test -- --runInBand
  • npm run build

Closes #741

@miachillgood miachillgood marked this pull request as ready for review June 19, 2026 12:07
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.

Error thrown is a String

1 participant