Skip to content

feat(error): Add superArgsFn to createCustomError for flexible base-class argument mapping#522

Merged
nev21 merged 6 commits intomainfrom
copilot/add-custom-error-creation
Feb 26, 2026
Merged

feat(error): Add superArgsFn to createCustomError for flexible base-class argument mapping#522
nev21 merged 6 commits intomainfrom
copilot/add-custom-error-creation

Conversation

Copy link
Contributor

Copilot AI commented Feb 25, 2026

  • Understand the existing createCustomError implementation
  • Add optional superArgsFn parameter to createCustomError that transforms constructor args before passing to base class
  • Update TypeScript interfaces/types (parameter signature update)
  • Add TSDoc documentation examples showing the new superArgsFn parameter
  • Add (since v0.12.7) to superArgsFn parameter documentation
  • Widen superArgsFn return type from any[] to ArrayLike<any>
  • Add tests for the new feature (4 new test cases covering reordering, subset, custom base class, and null superArgsFn)
  • Build and verify tests pass (841 node tests, no lint errors)
Original prompt

This section details on the original issue you should resolve

<issue_title>[Feature] Support the creation of custom errors where the order of arguments can be different</issue_title>
<issue_description>We need the ability to define custom errors where the order of the arguments does not need to be in the same order and type as the base class. But rather we need to define them in a style like classes where the super call specifies the order of the arguments to the base class.</issue_description>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

…ordering

Co-authored-by: nev21 <82737406+nev21@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for creating custom errors with flexible argument order feat(error): Add superArgsFn to createCustomError for flexible base-class argument mapping Feb 25, 2026
Copilot AI requested a review from nev21 February 25, 2026 16:43
Copy link
Contributor

@nev21 nev21 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot review comments

Co-authored-by: nev21 <82737406+nev21@users.noreply.github.com>
Copilot AI requested a review from nev21 February 26, 2026 01:50
@nev21 nev21 marked this pull request as ready for review February 26, 2026 01:54
@nev21 nev21 requested review from a team as code owners February 26, 2026 01:54
Copilot AI review requested due to automatic review settings February 26, 2026 01:54
Copy link
Contributor

@nev21 nev21 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nev21 nev21 enabled auto-merge (squash) February 26, 2026 01:55
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new optional superArgsFn argument to createCustomError() so callers can remap/reorder constructor arguments before invoking the base error constructor, matching super(...)-style behavior for custom error factories.

Changes:

  • Extended createCustomError() with an optional superArgsFn parameter and updated its TSDoc with examples.
  • Updated the implementation to pass either mapped args (superArgsFn) or the original args (default behavior) to the base constructor.
  • Added common tests covering argument reordering/subsetting, custom base classes, and null behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
lib/src/helpers/customError.ts Adds superArgsFn API + docs and uses it to transform args passed to the base error constructor.
lib/test/src/common/helpers/throw.test.ts Adds test coverage for createCustomError with superArgsFn across several scenarios.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: nev21 <82737406+nev21@users.noreply.github.com>
auto-merge was automatically disabled February 26, 2026 02:16

Head branch was pushed to by a user without write access

Copy link
Contributor Author

Copilot AI commented Feb 26, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • www.googleapis.com
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node install.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI requested a review from nev21 February 26, 2026 02:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@nev21 nev21 enabled auto-merge (squash) February 26, 2026 02:37
Copy link
Contributor

@nev21 nev21 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@codecov
Copy link

codecov bot commented Feb 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.71%. Comparing base (dae9534) to head (2aae5c9).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #522      +/-   ##
==========================================
- Coverage   98.71%   98.71%   -0.01%     
==========================================
  Files         111      111              
  Lines        3198     3197       -1     
  Branches      653      673      +20     
==========================================
- Hits         3157     3156       -1     
  Misses         41       41              
Files with missing lines Coverage Δ
lib/src/helpers/customError.ts 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@nevware21-bot nevware21-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved by nevware21-bot

@nev21 nev21 merged commit 88823af into main Feb 26, 2026
14 checks passed
@nev21 nev21 deleted the copilot/add-custom-error-creation branch February 26, 2026 04:02
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.

[Feature] Support the creation of custom errors where the order of arguments can be different

4 participants