Conversation
…ordering Co-authored-by: nev21 <82737406+nev21@users.noreply.github.com>
superArgsFn to createCustomError for flexible base-class argument mapping
Co-authored-by: nev21 <82737406+nev21@users.noreply.github.com>
There was a problem hiding this comment.
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 optionalsuperArgsFnparameter 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
nullbehavior.
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>
Head branch was pushed to by a user without write access
|
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:
If you need me to access, download, or install something from one of these locations, you can either:
|
Codecov Report✅ All modified and coverable lines are covered by tests. 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
🚀 New features to boost your workflow:
|
nevware21-bot
left a comment
There was a problem hiding this comment.
Approved by nevware21-bot
createCustomErrorimplementationsuperArgsFnparameter tocreateCustomErrorthat transforms constructor args before passing to base classsuperArgsFnparameter(since v0.12.7)tosuperArgsFnparameter documentationsuperArgsFnreturn type fromany[]toArrayLike<any>Original prompt
🔒 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.