Skip to content

fix: use Carp for error messages to report caller location#58

Draft
toddr-bot wants to merge 1 commit intomainfrom
koan.toddr.bot/use-carp-for-errors
Draft

fix: use Carp for error messages to report caller location#58
toddr-bot wants to merge 1 commit intomainfrom
koan.toddr.bot/use-carp-for-errors

Conversation

@toddr-bot
Copy link
Copy Markdown
Collaborator

@toddr-bot toddr-bot commented Apr 6, 2026

What

Switch die/warn to Carp::croak/carp so error messages point to the caller's code, not IO::Stty internals.

Why

When a user passes invalid parameters to stty(), the error message currently says "at lib/IO/Stty.pm line 503" — useless for debugging. With croak/carp, it reports the line in their code that made the bad call. Standard practice for CPAN modules.

How

  • die("No parameters passed to stty")croak(...) — the only fatal error
  • Five warn calls → carp (removed trailing \n so Carp appends caller info)
  • Added use Carp;

Testing

All 147 tests pass (including POD coverage). Existing warning-capture tests use substring regex matching, so the added caller info doesn't break them.


🤖 Generated with Claude Code


Quality Report

Changes: 1 file changed, 7 insertions(+), 6 deletions(-)

Code scan: clean

Tests: passed (OK)

Branch hygiene: 1 issue(s)

  • Branch is not pushed to remote

Generated by Kōan post-mission quality pipeline

Module errors now point to the caller's code instead of IO::Stty
internals. die→croak for the no-args error, warn→carp for invalid
parameters, unknown baud rates, and unrecognized char values.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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