Skip to main content

ephemeris_forge_github/config/
error.rs

1use ephemeris_forge::VariableNameError;
2
3use super::{ActorType, EnvironmentName, KeyPrefix, RulesetName, WebhookUrl};
4
5/// A configuration value that decodes but GitHub would refuse.
6#[derive(Debug, thiserror::Error)]
7pub enum ConfigError {
8    /// An autolink URL template has nowhere to put the reference number.
9    #[error("autolink \"{key_prefix}\" has a URL template without <num>")]
10    AutolinkTemplateWithoutNumber {
11        /// The autolink's key prefix.
12        key_prefix: KeyPrefix,
13    },
14    /// A webhook declares no events.
15    #[error("webhook \"{url}\" declares no events")]
16    EmptyWebhookEvents {
17        /// The webhook's delivery URL.
18        url: WebhookUrl,
19    },
20    /// A wait timer is longer than GitHub allows.
21    #[error("environment \"{environment}\" waits {minutes} minutes, GitHub allows at most 43200")]
22    EnvironmentWaitTimer {
23        /// The environment's name.
24        environment: EnvironmentName,
25        /// The configured minutes.
26        minutes: u32,
27    },
28    /// An environment has more reviewers than GitHub allows.
29    #[error("environment \"{environment}\" has {count} reviewers, GitHub allows at most 6")]
30    TooManyEnvironmentReviewers {
31        /// The environment's name.
32        environment: EnvironmentName,
33        /// The configured reviewer count.
34        count: usize,
35    },
36    /// GitHub rejects protected branches and custom branch policies together.
37    #[error(
38        "environment \"{environment}\" sets both protected_branches and custom_branch_policies"
39    )]
40    ConflictingDeploymentBranchPolicy {
41        /// The environment's name.
42        environment: EnvironmentName,
43    },
44    /// Branch policies need custom branch policies to be on.
45    #[error("environment \"{environment}\" has branch policies but custom_branch_policies is off")]
46    BranchPoliciesWithoutCustom {
47        /// The environment's name.
48        environment: EnvironmentName,
49    },
50    /// A bypass actor of this type needs an `actor_id`.
51    #[error("ruleset \"{ruleset}\" has a {actor_type} bypass actor without an actor_id")]
52    MissingActorId {
53        /// The ruleset's name.
54        ruleset: RulesetName,
55        /// The type of the bypass actor that lacks an id.
56        actor_type: ActorType,
57    },
58    /// A bypass actor of this type must not have an `actor_id`.
59    #[error("ruleset \"{ruleset}\" has a {actor_type} bypass actor with an actor_id")]
60    UnexpectedActorId {
61        /// The ruleset's name.
62        ruleset: RulesetName,
63        /// The type of the bypass actor that has an id.
64        actor_type: ActorType,
65    },
66    /// A pull request rule that allows no merge method blocks every merge.
67    #[error("ruleset \"{ruleset}\" allows no merge method")]
68    NoMergeMethods {
69        /// The ruleset's name.
70        ruleset: RulesetName,
71    },
72    /// An Actions variable name is not one GitHub stores.
73    #[error(transparent)]
74    VariableName(#[from] VariableNameError),
75}