refactor: normalize empty-pad-string error construction in string/left-pad and string/right-pad#12990
Draft
Planeshifter wants to merge 2 commits into
Draft
refactor: normalize empty-pad-string error construction in string/left-pad and string/right-pad#12990Planeshifter wants to merge 2 commits into
string/left-pad and string/right-pad#12990Planeshifter wants to merge 2 commits into
Conversation
Wrap the empty-pad-string `RangeError` message in `format()` so the throw matches the four other `format()`-wrapped throws in the same file. Conforms to the namespace-wide `format()` convention used by 55 of 56 leaf packages in `@stdlib/string`.
Wrap the empty-pad-string `RangeError` message in `format()` so the throw matches the four other `format()`-wrapped throws in the same file. Conforms to the namespace-wide `format()` convention used by 55 of 56 leaf packages in `@stdlib/string`.
Contributor
Coverage Report
The above coverage report was generated for the changes in this PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
@stdlib/string/left-padand@stdlib/string/right-padeach have a single residual plain-stringthrow new RangeError( '...' )at the empty-pad-string check that was missed during the migration to the canonicalformat()error-construction style. Every other throw in each file — including the adjacentRangeErrorguarding the maximum-string-length check — already wraps its message informat(). This pull request wraps the two empty-pad-string throws informat()to match. Across the 56 leaf packages in@stdlib/string, 114 of 117throw new ...Error(...)calls already useformat(); these two outliers were the only non-arity-guard residuals.@stdlib/string/left-padThe
p.length === 0check throws a plain-stringRangeError. The four other throws inlib/main.js— three argument-validationTypeErrors and the max-lengthRangeErrortwo lines below — already wrap their messages informat().formatis already imported. Wrap the empty-pad-string message informat()so the file is internally consistent. Error class and message text are unchanged.@stdlib/string/right-padSame drift as
left-pad: a single plain-stringRangeErrorat thep.length === 0check, surrounded byformat()-wrapped throws. Wrap the message informat(). Error class and message text are unchanged.Related Issues
No.
Questions
No.
Other
Pattern is identical to PR #12985 (
@stdlib/ndarray/iter).from-code-point/lib/main.jshas a related plain-stringthrow new Error( 'insufficient arguments...' )arity guard that is deliberately excluded per the convention established in PR #12227: arity-guard "insufficient arguments" plain messages are the stdlib-wide norm and should not be normalized.Tests assert only the
RangeErrorclass, not the message text. REPL docs and TypeScript declarations paraphrase the throw in a@throwstag and do not quote the runtime message. No sibling package in@stdlib/string/references either message string.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was authored by Claude Code on behalf of @Planeshifter as an automated cross-package API-drift audit of
@stdlib/string. Candidate corrections were located via filesystem and source-string feature extraction across all 58 namespace members, validated by three parallel reviewer agents (opus semantic-review, opus cross-reference, sonnet structural-review), then applied as one mechanical patch per package in the primary worktree. A human will audit and promote the PR out of draft.@stdlib-js/reviewers
Generated by Claude Code