Skip to content

refactor: centralize 7 scattered error classes into VeryfrontError + slug registry - #247

Merged
kojiwakayama merged 3 commits into
mainfrom
chore/centralize-scattered-errors
Feb 6, 2026
Merged

kojiwakayama merged 3 commits into
mainfrom
chore/centralize-scattered-errors

Conversation

@kojiwakayama

@kojiwakayama kojiwakayama commented Feb 6, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #246. Migrates 7 error classes that bypass the centralized system into the VeryfrontError + slug registry pattern.

Full plan: plans/centralize_scattered_errors.md


Errors Centralized (7)

Slug Replaces Category Default Status
api-client-error VeryfrontAPIError SERVER 500 (overridable)
config-validation-failed ConfigValidationError CONFIG 400
security-violation SecurityError GENERAL 403
input-validation-failed ValidationError GENERAL 400
token-storage-error TokenStorageError SERVER 500 (overridable)
cache-invariant-violation CacheInvariantError (2 classes) SERVER 500
fallback-exhausted FallbackExecutionError SERVER 500

API Changes to types.ts

  • ErrorCreateOptions.status?: number — allows per-request status override (e.g., API client errors vary by response)
  • ErrorCreateOptions.cause?: unknown — supports standard Error chaining (not just RFC 9457 string cause)
  • defineError().create() uses options.status ?? definition.status for status resolution
  • toRFC9457() only serializes string causes; Error objects are omitted from the RFC response

Intentionally Local (5 — not migrating)

SemaphoreTimeoutError, TransformTreeTimeoutError, NotSupportedError, TimeoutError, StreamTimeoutError — internal control-flow errors caught close to throw sites.


Tasks

Phase 1: Add definitions to registry

  • 1.1 Add 7 slug definitions to error-registry.ts
  • 1.2 Add tests for new slugs

Phase 2: Migrate each error class

  • 2.1 VeryfrontAPIError → api-client-error (14 files)
  • 2.2 ConfigValidationError → config-validation-failed (1 file)
  • 2.3 SecurityError → security-violation (2 files)
  • 2.4 ValidationError → input-validation-failed (19 files)
  • 2.5 TokenStorageError → token-storage-error (7 files)
  • 2.6 CacheInvariantError → cache-invariant-violation (6 files)
  • 2.7 FallbackExecutionError → fallback-exhausted (4 files)

Phase 3: Delete old error classes

  • 3.1–3.7 Delete each original class definition (replaced with re-exports)

Phase 4: Verify

  • 4.1 Only 5 intentionally local extends Error classes remain
  • 4.2 All 909 unit tests pass (0 failures)
  • 4.3 Rebased on main — integrated with new registry (69 → 76 definitions)

@ariskemper ariskemper changed the title chore: plan for centralizing scattered error classes refactor: centralize 7 scattered error classes into VeryfrontError + slug registry Feb 6, 2026
7 error classes extend plain Error instead of VeryfrontError and bypass
the centralized slug registry. This plan migrates them after the main
error codes refactoring (PR #246) is complete.

Also documents 5 intentionally local control-flow errors that should
remain as-is.
@ariskemper
ariskemper marked this pull request as draft February 6, 2026 16:00
…slug registry

Replace 7 classes that extended plain Error with a centralized error
registry pattern using VeryfrontError + unique slugs for identification.

Migrated errors:
- VeryfrontAPIError → API_CLIENT_ERROR (api-client-error)
- ConfigValidationError → CONFIG_VALIDATION_FAILED (config-validation-failed)
- SecurityError → SECURITY_VIOLATION (security-violation)
- ValidationError → INPUT_VALIDATION_FAILED (input-validation-failed)
- TokenStorageError → TOKEN_STORAGE_ERROR (token-storage-error)
- CacheInvariantError → CACHE_INVARIANT_VIOLATION (cache-invariant-violation)
- FallbackExecutionError → FALLBACK_EXHAUSTED (fallback-exhausted)
@ariskemper
ariskemper force-pushed the chore/centralize-scattered-errors branch from bab9105 to e05f09d Compare February 6, 2026 16:09
@ariskemper
ariskemper marked this pull request as ready for review February 6, 2026 16:11
- Move CACHE_INVARIANT_VIOLATION import to top of cache/paths.ts
- Add doc comment to CONFIG_VALIDATION_ERROR to distinguish it from
  CONFIG_VALIDATION_FAILED (schema-level 422 vs file-level 400)
@kojiwakayama
kojiwakayama merged commit 863cd51 into main Feb 6, 2026
11 checks passed
@kojiwakayama
kojiwakayama deleted the chore/centralize-scattered-errors branch February 6, 2026 16:46
kojiwakayama added a commit that referenced this pull request Feb 6, 2026
…nd fix error class imports

- Unify isAbsolutePath: enhance platform compat layer's isAbsolute to handle
  Windows drive letters and UNC paths, re-export from path-utils.ts and
  security/normalization.ts instead of maintaining separate implementations
- Remove legacy runtime-errors.ts and its tests (FileSystemError, NetworkError
  already migrated to VeryfrontError slug registry in PR #247)
- Update init-command.ts, page-loader.ts, and client-hydrator.ts to use
  VeryfrontError.create() instead of deleted FileSystemError/NetworkError classes
- Deduplicate remaining CLI utility imports (formatError, ensureDir) in
  actions.ts, server-checks.ts, helpers.ts, and integration-generator.ts
- Fix pre-existing deno fmt violation in client-hydrator.ts
ariskemper added a commit that referenced this pull request Feb 9, 2026
…slug registry (#247)

* chore: add plan for centralizing scattered error classes

7 error classes extend plain Error instead of VeryfrontError and bypass
the centralized slug registry. This plan migrates them after the main
error codes refactoring (PR #246) is complete.

Also documents 5 intentionally local control-flow errors that should
remain as-is.

* refactor: centralize 7 scattered error classes into VeryfrontError + slug registry

Replace 7 classes that extended plain Error with a centralized error
registry pattern using VeryfrontError + unique slugs for identification.

Migrated errors:
- VeryfrontAPIError → API_CLIENT_ERROR (api-client-error)
- ConfigValidationError → CONFIG_VALIDATION_FAILED (config-validation-failed)
- SecurityError → SECURITY_VIOLATION (security-violation)
- ValidationError → INPUT_VALIDATION_FAILED (input-validation-failed)
- TokenStorageError → TOKEN_STORAGE_ERROR (token-storage-error)
- CacheInvariantError → CACHE_INVARIANT_VIOLATION (cache-invariant-violation)
- FallbackExecutionError → FALLBACK_EXHAUSTED (fallback-exhausted)

* style: move import to top of file and add doc comments for clarity

- Move CACHE_INVARIANT_VIOLATION import to top of cache/paths.ts
- Add doc comment to CONFIG_VALIDATION_ERROR to distinguish it from
  CONFIG_VALIDATION_FAILED (schema-level 422 vs file-level 400)

---------

Co-authored-by: ariskemper <aris.github@gmail.com>
kojiwakayama added a commit that referenced this pull request Aug 17, 2026
…dbox

- teams/confluence template clients: strip HTML tags to a fixed point and
  decode &amp; last, closing incomplete-multi-character-sanitization and
  double-escaping findings (alerts #276-#278)
- push command: drop the dead pushedSourceDigest initializer — every path
  that reads it reassigns via computePushedSourceDigest, which revalidates
  remote content itself (alert #285)
- worker-script: remove a null comparison already excluded by the early
  return at the top of snapshotStructuredData (alert #247)
- execution-support test: call throwIfChildRunAborted directly instead of
  asserting the return value of a void function (alerts #279/#280)
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.

2 participants