Skip to content

Migrate remaining RangeLinkError usages to RangeLinkExtensionError #619

@couimet

Description

@couimet

RangeLinkError (from rangelink-core-ts) is DetailedError<RangeLinkErrorCodes>. RangeLinkExtensionError (in the extension package) is DetailedError<RangeLinkExtensionErrorCodes>. Every module in the extension package that instantiates or returns errors should use RangeLinkExtensionError. Currently, some modules still use RangeLinkError.

This is a follow-up to work done on the issues/609 branch, which already:

  • Added RangeLinkSpecificCodes to RangeLinkExtensionErrorCodes (type union + const merge)
  • Migrated ClipboardService, TerminalSelectionService, and TerminalPasteService (+ their tests)

Remaining RangeLinkError usages (13 files, ~100 usages)

Category A: Production config code (13 usages in 4 files)

Self-contained delimiter validation module. Errors are collected as arrays and logged; they don't flow into the broader extension error pipeline.

  • config/validation.ts (7): Instantiates RangeLinkError for CONFIG_DELIMITER_* codes
  • config/types.ts (2): Type annotations on LoadDelimiterConfigResult
  • config/loadDelimiterConfig.ts (2): Import + type in createDefaultResult
  • config/logging.ts (2): Import + parameter type

Category B: Custom Jest matchers (77 usages in 3 files)

Test infrastructure providing the toBeRangeLinkError matcher.

  • tests/setup/matchers.ts (13): Matcher type declarations
  • tests/matchers/toBeRangeLinkError.ts (25): Matcher implementation
  • tests/matchers/toBeRangeLinkError.test.ts (39): Matcher tests

Category C: Test files (10 usages in 6 files)

Tests that instantiate RangeLinkError or use the toBeRangeLinkError matcher.

  • tests/services/TerminalPasteService.test.ts (3)
  • tests/commands/GoToRangeLinkCommand.test.ts (2)
  • tests/utils/generateLinkFromSelections.test.ts (2)
  • tests/services/SendRouter.test.ts (1)
  • tests/destinations/capabilities/insertFactories/terminalInsertFactory.test.ts (1)
  • tests/navigation/RangeLinkNavigationHandler.test.ts (1)

Proposed approach

Three passes, each tested independently:

  1. Config module — switch config/ from RangeLinkError to RangeLinkExtensionError
  2. Custom matchers — add RangeLinkExtensionError overloads (or new matcher) so both error types work
  3. Remaining test files — switch imports/instantiations to RangeLinkExtensionError

No urgency — the remaining RangeLinkError modules don't interoperate with migrated services through Result<T, E> chains, so there are no type incompatibilities.

Metadata

Metadata

Assignees

Labels

priority:lowLow priority / nice to havescope:vscode-extrangelink-vscode-extension packagetype:debtTechnical debt that needs to be addressedtype:refactorCode refactoring without behavior change

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions