Skip to content

feat: More classed errors#55

Merged
trevorld merged 1 commit into
masterfrom
structured-errors
Mar 27, 2026
Merged

feat: More classed errors#55
trevorld merged 1 commit into
masterfrom
structured-errors

Conversation

@trevorld

Copy link
Copy Markdown
Owner
  • Several new classed errors are now thrown, mirroring Python's optparse exception hierarchy:

    • optparse_option_error — invalid option definition in make_option() or add_option().

      • optparse_option_conflict_error — duplicate flag in OptionParser() or add_option().
    • optparse_parse_error — existing base class for all parse-time errors from parse_args().

      • optparse_bad_option_error — unrecognized, misused, or argument-requiring option.
        • optparse_ambiguous_option_error — ambiguous abbreviated long flag.
      • optparse_bad_positional_arguments_error — wrong number of positional arguments supplied.
  • Also refactor to use internal (mockable) is_interactive() and improve some tests and error wordings.

* Several new classed errors are now thrown, mirroring Python's `optparse` exception hierarchy:

  + `optparse_option_error` — invalid option definition in `make_option()` or `add_option()`.
    - `optparse_option_conflict_error` — duplicate flag in `OptionParser()` or `add_option()`.

  + `optparse_parse_error` — existing base class for all parse-time errors from `parse_args()`.
    - `optparse_bad_option_error` — unrecognized, misused, or argument-requiring option.
      * `optparse_ambiguous_option_error` — ambiguous abbreviated long flag.
    - `optparse_bad_positional_arguments_error` — wrong number of positional arguments supplied.

* Also refactor to use internal (mockable) `is_interactive()` and improve some tests and error wordings.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@trevorld
trevorld merged commit 3efed2d into master Mar 27, 2026
5 checks passed
@trevorld
trevorld deleted the structured-errors branch March 27, 2026 18:10
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.

1 participant