Skip to main content

jj_hooks/
error.rs

1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum JjHooksError {
5    #[error("jj exited with status {status}: {stderr}")]
6    JjFailed { status: i32, stderr: String },
7
8    #[error("setup step `{name}` exited with status {status}")]
9    SetupFailed { name: String, status: i32 },
10
11    #[error("could not parse `jj git push --dry-run` output: {0}")]
12    Parse(String),
13
14    /// The configured runner binary couldn't be found through any of the
15    /// resolution layers. Includes the binary name and a hint mentioning
16    /// the most common causes (Python venv that wasn't activated, runner
17    /// not installed globally, no `jj-hooks.runner-bin.<runner>` override).
18    #[error(
19        "hook runner `{bin}` could not be resolved.\n\
20         jj-hp looked at: (1) `jj-hooks.runner-bin.{bin}` config, \
21         (2) `.git/hooks/<stage>` shim from `prek install`, \
22         (3) `uv run --` when `uv.lock` + `uv` are present (prek/pre-commit only), \
23         (4) `$PATH`.\n\
24         hint: install it globally (e.g. `brew install {bin}` / `pipx install {bin}` / `uv tool install {bin}`), \
25         or set `jj-hooks.runner-bin.{bin} = \"…\"` in your jj config to point at the binary explicitly."
26    )]
27    RunnerNotFound { bin: String },
28
29    #[error(transparent)]
30    Io(#[from] std::io::Error),
31}
32
33pub type Result<T> = std::result::Result<T, JjHooksError>;