|
2 | 2 | // |
3 | 3 | // SPDX-License-Identifier: GPL-3.0-only |
4 | 4 |
|
| 5 | +// miette's Diagnostic derive generates code that triggers this false positive |
| 6 | +#![allow(unused_assignments)] |
| 7 | + |
| 8 | +use miette::Diagnostic; |
5 | 9 | use thiserror::Error; |
6 | 10 |
|
7 | | -#[derive(Error, Debug)] |
| 11 | +#[derive(Error, Diagnostic, Debug)] |
8 | 12 | pub enum Error { |
9 | | - #[error("No staged changes found. Use `git add` to stage files.")] |
| 13 | + #[error("No staged changes found")] |
| 14 | + #[diagnostic(code(commitbee::git::no_staged), help("Stage files with: git add <files>"))] |
10 | 15 | NoStagedChanges, |
11 | 16 |
|
12 | | - #[error("Not a git repository. Run from a git project directory.")] |
| 17 | + #[error("Not a git repository")] |
| 18 | + #[diagnostic( |
| 19 | + code(commitbee::git::not_repo), |
| 20 | + help("Run this command inside a git repository") |
| 21 | + )] |
13 | 22 | NotAGitRepo, |
14 | 23 |
|
15 | | - #[error("Merge conflicts detected. Resolve conflicts before committing.")] |
| 24 | + #[error("Merge conflicts detected")] |
| 25 | + #[diagnostic( |
| 26 | + code(commitbee::git::conflicts), |
| 27 | + help("Resolve conflicts before committing") |
| 28 | + )] |
16 | 29 | MergeConflicts, |
17 | 30 |
|
18 | | - #[error("Merge in progress. Complete or abort the merge first.")] |
| 31 | + #[error("Merge in progress")] |
| 32 | + #[diagnostic( |
| 33 | + code(commitbee::git::merge), |
| 34 | + help("Complete or abort the merge: git merge --abort") |
| 35 | + )] |
19 | 36 | MergeInProgress, |
20 | 37 |
|
21 | | - #[error("Operation cancelled by user.")] |
| 38 | + #[error("Operation cancelled by user")] |
22 | 39 | Cancelled, |
23 | 40 |
|
24 | | - #[error("Potential secrets detected: {patterns:?}. Use --allow-secrets to proceed.")] |
| 41 | + #[error("Potential secrets detected: {patterns:?}")] |
| 42 | + #[diagnostic( |
| 43 | + code(commitbee::safety::secrets), |
| 44 | + help("Use --allow-secrets with local Ollama only") |
| 45 | + )] |
25 | 46 | SecretsDetected { patterns: Vec<String> }, |
26 | 47 |
|
27 | | - #[error("Cannot connect to Ollama at {host}. Is it running?")] |
| 48 | + #[error("Cannot connect to Ollama at {host}")] |
| 49 | + #[diagnostic( |
| 50 | + code(commitbee::ollama::not_running), |
| 51 | + help("Start Ollama with: ollama serve") |
| 52 | + )] |
28 | 53 | OllamaNotRunning { host: String }, |
29 | 54 |
|
30 | 55 | #[error("Model '{model}' not found. Available: {}", available.join(", "))] |
| 56 | + #[diagnostic( |
| 57 | + code(commitbee::ollama::model_not_found), |
| 58 | + help("Pull the model with: ollama pull {model}") |
| 59 | + )] |
31 | 60 | ModelNotFound { |
32 | 61 | model: String, |
33 | 62 | available: Vec<String>, |
34 | 63 | }, |
35 | 64 |
|
36 | 65 | #[error("Provider '{provider}' error: {message}")] |
| 66 | + #[diagnostic(code(commitbee::provider::error))] |
37 | 67 | Provider { provider: String, message: String }, |
38 | 68 |
|
39 | 69 | #[error("Invalid commit message: {0}")] |
| 70 | + #[diagnostic(code(commitbee::commit::invalid))] |
40 | 71 | InvalidCommitMessage(String), |
41 | 72 |
|
42 | 73 | #[error("Configuration error: {0}")] |
| 74 | + #[diagnostic(code(commitbee::config::error))] |
43 | 75 | Config(String), |
44 | 76 |
|
45 | 77 | #[error("Git error: {0}")] |
| 78 | + #[diagnostic(code(commitbee::git::error))] |
46 | 79 | Git(String), |
47 | 80 |
|
48 | 81 | #[error(transparent)] |
|
0 commit comments