refactor: improve miette error handling adoption#177
Merged
Conversation
Contributor
There was a problem hiding this comment.
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 returnmiette::Result<()>usingensure!macros for richer error diagnostics - Replaced panic-inducing
unimplemented!()withbail!()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>
07d693e to
c9c628b
Compare
Merged
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Improves miette error handling adoption across the codebase:
validate_daemon_id()now returnsmiette::Result<()>usingensure!macro instead ofResult<(), String>- provides richer error diagnosticsunimplemented!()withbail!()inactivate.rsfor unsupported shells - gives users a proper error message instead of a panicwrap_err()for better error messages when IPC operations failFiles Changed
src/daemon.rsvalidate_daemon_id()to useensure!macrosrc/cli/activate.rsunimplemented!()withbail!()src/ipc/client.rsContexttrait andwrap_err()for better error contextsrc/supervisor.rs.to_string()on miette errors for IPC responsesTest plan
cargo nextest run)cargo clippy --all-targets --all-features -- -D warnings)cargo fmt --check)🤖 Generated with Claude Code
Note
Centralizes error handling on
miettefor clearer diagnostics and safer failures.validate_daemon_id()to returnResult<()>usingensure!; adjust tests to assert on error messagesunimplemented!()withbail!()for unsupported shells incli/activate.rsContext::wrap_err()and improve messages inipc/client.rsfor send/read/deserialize failures; clarify closed-connection errormietteerrors forIpcResponse::ErrorWritten by Cursor Bugbot for commit c9c628b. This will update automatically on new commits. Configure here.