Skip to content

Preserve plain-object rejection reasons in global error handlers#181

Open
FeironoX5 wants to merge 13 commits intomasterfrom
fix/plain-object-rejection-new
Open

Preserve plain-object rejection reasons in global error handlers#181
FeironoX5 wants to merge 13 commits intomasterfrom
fix/plain-object-rejection-new

Conversation

@FeironoX5
Copy link
Copy Markdown
Contributor

Closes #171

Fix global error normalization so plain-object promise rejection reasons are captured as readable payloads instead of "[object Object]".

PR Description

Fix error normalization for global error handlers so rejected plain objects are preserved instead of being collapsed into "[object Object]".

This PR introduces a normalized CapturedError shape and uses it across the main catcher and console catcher. For unhandledrejection, plain-object reasons are now serialized into a readable title instead of going through String(obj). For browser ErrorEvents, the catcher now also builds a more useful fallback message when the original error object is unavailable (for example, cross-origin script errors).

Changes

  • Added fillCapturedError and getErrorFromErrorEvent helpers in src/utils/error.ts
  • Switched Catcher internals from Error | string to normalized CapturedError
  • Reused normalized error extraction in consoleCatcher
  • Preserved original rawError reference for deduplication/backtrace logic
  • Added tests for:
    • Error
    • DOMException
    • plain-object promise rejection reasons
    • string / null / undefined rejection reasons
    • circular objects
    • cross-origin-style ErrorEvent fallback
изображение

@FeironoX5 FeironoX5 force-pushed the fix/plain-object-rejection-new branch from f3c071b to f450310 Compare April 11, 2026 08:15
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.

Bad plain object handling as PromiseRejectionEvent reason

2 participants