Skip to content

refactor(exceptions): an exception class declares its error_code and exit_code, and the forwarding __init__ methods, unused classes and CONST_ERROR_CODE constants go #2490

Closed

Description

@dan-petty

Problem or Motivation

Part 2 of #1006. The exception package (src/devops_cli/exceptions/, 96 classes, checked at origin/main 08d70ca, 2026-10-28) states each error code three ways, and most of its code only repeats the base class:

  • 32 classes have an __init__ whose only statement is super().__init__(...).
  • 46 CONST_ERROR_CODE_* constants in src/devops_cli/config/constants.py. Their only importers are the exception modules and ai/rag/embeddings.py.
  • Some classes are never raised in src. The change lists them with the search that shows no raise and no except.

Proposed Solution & Architectural Design

  • DevOpsCLIError reads error_code and exit_code from class attributes. Each class declares its own. Domain bases add only their structured-detail keys.
  • The __init__ methods that only forward to the base are deleted.
  • Classes that no code raises, catches or re-exports are deleted.
  • The CONST_ERROR_CODE_* constants become class data, and config/constants.py keeps none of them.
  • tests/test_exceptions.py checks a table built from the class hierarchy: one error code maps to one exit status.
  • docs/ERRORS.md is regenerated and lists the same codes and exit statuses as before.
  • The documents that name CONST_ERROR_CODE_* say that an exception class declares its error_code and exit_code.

Target Subsystem

src/devops_cli/exceptions/, src/devops_cli/config/constants.py, docs/ERRORS.md.

Existing Tool Considered

Python class attributes hold the codes. No library is needed, and the change deletes code.

Acceptance criteria

  • Each error code and exit status in docs/ERRORS.md is the same before and after the change.
  • config/constants.py holds no CONST_ERROR_CODE_*.
  • No exception class has an __init__ that only calls super().__init__.
  • The tests run offline.

Related

Parent: #1006. Sibling: one exit seam for every command.

Source: #1006

Activity

  1. added
    source/agent
    type/refactor
    status/new
    value/medium
    effort/medium
    on Oct 28, 2026
  2. dan-petty commented on Oct 28, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/refactor. The change restructures exception class declarations without altering user-facing behaviour.
    • Priority: P2-Medium. It simplifies 96 classes and removes dead code, improving maintainability but not fixing a user-facing defect.
    • Value: Medium. It reduces code duplication and makes the exception hierarchy self-documenting for developers.
    • Effort: Medium. It touches 96 classes, a constants file, tests and docs, but the edits are mechanical.
    • Related: fix(cli): every command reports a DevOpsCLIError through one exit seam, with its exit status and no traceback #2487, which asks for a different change. Both are parts of #1006 working on the exception package, but 2487 fixes the exit seam mechanism while this item refactors how classes declare their codes.
  3. added
    priority/p2-medium
    on Oct 28, 2026
  4. removed
    status/new
    on Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumsource/agenttype/refactorvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions