You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Integrate the changes introduced in couimet/ts-npm-packages#63 into RangeLink, which adds a static forUnexpectedSwitchDefault() factory method to the DetailedError base class in the @couimet/detailed-error package.
Rationale
The new factory method standardizes error creation for unexpected switch/default cases across subclasses of DetailedError, reducing boilerplate and improving consistency in error messaging (Unexpected <label>: <JSON.stringify(value)>), while still allowing a code override for subclasses using standalone enums.
Required Changes
Bump the @couimet/detailed-error dependency (and @couimet/detailed-error-testing if used) in RangeLink to the version that includes PR [Phase 5.2] Regex escaping contracts #63.
Identify existing switch/default blocks in RangeLink that currently throw ad-hoc DetailedError instances (or UNEXPECTED_CODE_PATH equivalents) and replace them with calls to DetailedError.forUnexpectedSwitchDefault(...).
If RangeLink's test suite asserts on DetailedError instances, consider adopting the toBeDetailedError matcher from @couimet/detailed-error-testing for more readable assertions, mirroring the conversion done in PR [Phase 5.2] Regex escaping contracts #63.
Verify moduleNameMapper / Jest config changes are not needed on RangeLink's side (PR [Phase 5.2] Regex escaping contracts #63 required this in ts-npm-packages to keep a single DetailedError module instance during tests).
Affected Areas
RangeLink modules/files using DetailedError for unexpected switch/default handling
Jest configuration (if @couimet/detailed-error-testing is adopted)
package.json dependency versions
Acceptance Criteria
@couimet/detailed-error dependency updated to the version containing forUnexpectedSwitchDefault()
Existing unexpected switch/default error paths in RangeLink refactored to use DetailedError.forUnexpectedSwitchDefault()
Tests updated/passing, optionally using the toBeDetailedError matcher
No regressions in existing instanceof Error / instanceof DetailedError behavior
Summary
Integrate the changes introduced in couimet/ts-npm-packages#63 into RangeLink, which adds a
static forUnexpectedSwitchDefault()factory method to theDetailedErrorbase class in the@couimet/detailed-errorpackage.Rationale
The new factory method standardizes error creation for unexpected
switch/defaultcases across subclasses ofDetailedError, reducing boilerplate and improving consistency in error messaging (Unexpected <label>: <JSON.stringify(value)>), while still allowing acodeoverride for subclasses using standalone enums.Required Changes
@couimet/detailed-errordependency (and@couimet/detailed-error-testingif used) in RangeLink to the version that includes PR [Phase 5.2] Regex escaping contracts #63.switch/defaultblocks in RangeLink that currently throw ad-hocDetailedErrorinstances (orUNEXPECTED_CODE_PATHequivalents) and replace them with calls toDetailedError.forUnexpectedSwitchDefault(...).DetailedErrorinstances, consider adopting thetoBeDetailedErrormatcher from@couimet/detailed-error-testingfor more readable assertions, mirroring the conversion done in PR [Phase 5.2] Regex escaping contracts #63.moduleNameMapper/ Jest config changes are not needed on RangeLink's side (PR [Phase 5.2] Regex escaping contracts #63 required this ints-npm-packagesto keep a singleDetailedErrormodule instance during tests).Affected Areas
DetailedErrorfor unexpected switch/default handling@couimet/detailed-error-testingis adopted)package.jsondependency versionsAcceptance Criteria
@couimet/detailed-errordependency updated to the version containingforUnexpectedSwitchDefault()DetailedError.forUnexpectedSwitchDefault()toBeDetailedErrormatcherinstanceof Error/instanceof DetailedErrorbehaviorReferences
forUnexpectedSwitchDefault()toDetailedErrorts-npm-packages#63DetailedError.forUnexpectedSwitchDefault()to @couimet/detailed-error ts-npm-packages#53