Skip to content

refactor: improve miette error handling adoption#177

Merged
jdx merged 1 commit intomainfrom
refactor/improve-miette-adoption
Jan 19, 2026
Merged

refactor: improve miette error handling adoption#177
jdx merged 1 commit intomainfrom
refactor/improve-miette-adoption

Conversation

@jdx
Copy link
Owner

@jdx jdx commented Jan 19, 2026

Summary

Improves miette error handling adoption across the codebase:

  • validate_daemon_id() now returns miette::Result<()> using ensure! macro instead of Result<(), String> - provides richer error diagnostics
  • Replace unimplemented!() with bail!() in activate.rs for unsupported shells - gives users a proper error message instead of a panic
  • Add error context to IPC client using wrap_err() for better error messages when IPC operations fail
  • Update tests to work with miette error types

Files Changed

File Change
src/daemon.rs Convert validate_daemon_id() to use ensure! macro
src/cli/activate.rs Replace unimplemented!() with bail!()
src/ipc/client.rs Add Context trait and wrap_err() for better error context
src/supervisor.rs Update to call .to_string() on miette errors for IPC responses

Test plan

  • All 77 tests pass (cargo nextest run)
  • No clippy warnings (cargo clippy --all-targets --all-features -- -D warnings)
  • Format checks pass (cargo fmt --check)

🤖 Generated with Claude Code


Note

Centralizes error handling on miette for clearer diagnostics and safer failures.

  • Convert validate_daemon_id() to return Result<()> using ensure!; adjust tests to assert on error messages
  • Replace unimplemented!() with bail!() for unsupported shells in cli/activate.rs
  • Add Context::wrap_err() and improve messages in ipc/client.rs for send/read/deserialize failures; clarify closed-connection error
  • In supervisor IPC handlers, stringify miette errors for IpcResponse::Error

Written by Cursor Bugbot for commit c9c628b. This will update automatically on new commits. Configure here.

Copilot AI review requested due to automatic review settings January 19, 2026 18:31
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors error handling across the codebase to better adopt the miette error handling library, improving error diagnostics and user experience.

Changes:

  • Converted validate_daemon_id() to return miette::Result<()> using ensure! macros for richer error diagnostics
  • Replaced panic-inducing unimplemented!() with bail!() to provide proper error messages for unsupported shells
  • Enhanced IPC client error messages with context using wrap_err() for better debugging

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/daemon.rs Refactored validate_daemon_id() to use miette's ensure! macro and updated tests to work with miette error types
src/cli/activate.rs Replaced unimplemented!() with bail!() for unsupported shell handling
src/ipc/client.rs Added Context trait import and enhanced error messages with wrap_err()
src/supervisor.rs Updated error handling to call .to_string() on miette errors for IPC responses

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Convert validate_daemon_id() to return miette::Result using ensure! macro
- Replace unimplemented!() with bail!() in activate.rs for unsupported shells
- Add Context trait and wrap_err() for better IPC client error messages
- Update tests to work with miette error types

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@jdx jdx force-pushed the refactor/improve-miette-adoption branch from 07d693e to c9c628b Compare January 19, 2026 18:37
@jdx jdx merged commit 9612783 into main Jan 19, 2026
4 checks passed
@jdx jdx deleted the refactor/improve-miette-adoption branch January 19, 2026 18:57
@jdx jdx mentioned this pull request Jan 19, 2026
jdx added a commit that referenced this pull request Jan 20, 2026
## 🤖 New release

* `pitchfork-cli`: 1.1.0 -> 1.2.0

<details><summary><i><b>Changelog</b></i></summary><p>

<blockquote>

## [1.2.0](v1.1.0...v1.2.0) -
2026-01-19

### Added

- enhance miette error diagnostics with source highlighting and URLs
([#183](#183))
- add structured IPC error types with miette diagnostics
([#181](#181))
- add structured config error types with file path context
([#182](#182))
- add config editor to TUI for creating and editing daemons
([#171](#171))
- add custom diagnostic error types with miette
([#180](#180))

### Other

- improve miette error handling adoption
([#177](#177))
- modularize supervisor.rs into focused submodules
([#175](#175))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Release 1.2.0**
> 
> - Bump version to `1.2.0` in `Cargo.toml`, `Cargo.lock`,
`docs/cli/commands.json`, `docs/cli/index.md`, and `pitchfork.usage.kdl`
> - Regenerate CLI docs/usage specs to reflect the new version
> - Update `CHANGELOG.md` with highlights: enhanced `miette` diagnostics
(source highlighting, URLs), structured IPC/config error types, custom
diagnostic errors, TUI config editor; plus adoption improvements and
supervisor modularization
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
32b3259. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.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.

2 participants