Skip to main content

joy_core/
error.rs

1// Copyright (c) 2026 Joydev GmbH (joydev.com)
2// SPDX-License-Identifier: MIT
3
4use std::path::PathBuf;
5
6#[derive(Debug, thiserror::Error)]
7pub enum JoyError {
8    #[error("project already initialized at {0}")]
9    AlreadyInitialized(PathBuf),
10
11    #[error("no Joy project found (run `joy init` first)")]
12    NotInitialized,
13
14    #[error("item not found: {0}")]
15    ItemNotFound(String),
16
17    #[error("milestone not found: {0}")]
18    MilestoneNotFound(String),
19
20    #[error("circular dependency detected: {0}")]
21    CircularDependency(String),
22
23    #[error("failed to create directory {path}")]
24    CreateDir {
25        path: PathBuf,
26        source: std::io::Error,
27    },
28
29    #[error("failed to write {path}")]
30    WriteFile {
31        path: PathBuf,
32        source: std::io::Error,
33    },
34
35    #[error("failed to read {path}")]
36    ReadFile {
37        path: PathBuf,
38        source: std::io::Error,
39    },
40
41    #[error("{path}: {source}")]
42    YamlParse {
43        path: PathBuf,
44        source: serde_yaml_ng::Error,
45    },
46
47    #[error("YAML error: {0}")]
48    Yaml(#[from] serde_yaml_ng::Error),
49
50    #[error("git error: {0}")]
51    Git(String),
52
53    #[error("template error: {0}")]
54    Template(String),
55
56    #[error("authentication failed: {0}")]
57    AuthFailed(String),
58
59    #[error("passphrase too short (minimum 6 words)")]
60    PassphraseTooShort,
61
62    #[error("guard denied: {0}")]
63    GuardDenied(String),
64
65    #[error("{0}")]
66    Other(String),
67}