Skip to content

feat: add custom diagnostic error types with miette#180

Merged
jdx merged 1 commit intomainfrom
feat/miette-diagnostic-errors
Jan 19, 2026
Merged

feat: add custom diagnostic error types with miette#180
jdx merged 1 commit intomainfrom
feat/miette-diagnostic-errors

Conversation

@jdx
Copy link
Owner

@jdx jdx commented Jan 19, 2026

Summary

  • Add DaemonIdError enum with error codes and help text for daemon ID validation
  • Add DependencyError enum for dependency resolution errors with fuzzy matching suggestions
  • Migrate daemon.rs and deps.rs to use the new structured error types

Benefits

  • Error codes (pitchfork::daemon::*, pitchfork::deps::*) for better searchability
  • Contextual help messages explaining how to fix each error
  • "Did you mean?" suggestions when a daemon name isn't found
  • Cleaner, more maintainable error handling code

Example Output

Error: pitchfork::deps::not_found

  × daemon 'postgre' not found in configuration

  help: did you mean 'postgres'?

Test plan

  • All existing tests pass
  • New unit tests for error types in src/error.rs
  • Lints pass with cargo clippy

🤖 Generated with Claude Code


Note

Introduces a new error module with structured miette diagnostics and updates callers.

  • Add src/error.rs defining DaemonIdError and DependencyError (error codes, help text, fuzzy “did you mean?” suggestions)
  • Migrate daemon.rs::validate_daemon_id and deps.rs::resolve_dependencies to use these errors; adjust test assertions for new messages
  • Wire up module in lib.rs/main.rs; add thiserror and fuzzy-matcher dependencies

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

Introduce structured error types for better error reporting:

- DaemonIdError: validation errors with error codes and help text
- DependencyError: resolution errors with fuzzy matching suggestions

Benefits:
- Error codes (pitchfork::daemon::*, pitchfork::deps::*)
- Contextual help messages
- "Did you mean?" suggestions for daemon names
- Cleaner error handling in daemon.rs and deps.rs

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings January 19, 2026 19:06
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 introduces structured diagnostic error types using the miette library to provide better error messages with error codes, help text, and fuzzy matching suggestions for daemon and dependency-related errors.

Changes:

  • Added error.rs module with DaemonIdError and DependencyError enums
  • Migrated daemon.rs and deps.rs to use structured error types instead of generic error messages
  • Added thiserror dependency for error derive macros

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/main.rs Added error module declaration
src/lib.rs Exposed error module publicly
src/error.rs Implemented structured error types with diagnostic codes and help text
src/deps.rs Migrated to use DependencyError with fuzzy matching suggestions
src/daemon.rs Migrated to use DaemonIdError for validation errors
Cargo.toml Added thiserror v2 dependency

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

Comment on lines +6 to +7
// False positive: fields are used in #[error] format strings via thiserror derive
#![allow(unused_assignments)]
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

The comment mentions 'unused_assignments' is a false positive for fields used in #[error] format strings, but the actual lint being suppressed is for unused fields (dead_code), not assignments. The unused_assignments lint applies to variable assignments, not struct fields. Consider using #![allow(dead_code)] instead if that's the intended suppression.

Suggested change
// False positive: fields are used in #[error] format strings via thiserror derive
#![allow(unused_assignments)]
// False positive: fields are used in #[error] format strings via thiserror derive (dead_code)
#![allow(dead_code)]

Copilot uses AI. Check for mistakes.
Comment on lines +94 to +95
use fuzzy_matcher::FuzzyMatcher;
use fuzzy_matcher::skim::SkimMatcherV2;
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

The fuzzy_matcher dependency is used in this function but not declared in Cargo.toml. This will cause a compilation error. Add the fuzzy-matcher crate to the dependencies.

Copilot uses AI. Check for mistakes.
@jdx jdx merged commit 528947e into main Jan 19, 2026
4 checks passed
@jdx jdx deleted the feat/miette-diagnostic-errors branch January 19, 2026 19:37
@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