Skip to main content

alien_permissions/
error.rs

1use alien_error::AlienErrorData;
2use serde::{Deserialize, Serialize};
3
4/// Errors that occur in permission operations.
5#[derive(Debug, Clone, AlienErrorData, Serialize, Deserialize)]
6#[serde(rename_all = "camelCase")]
7pub enum ErrorData {
8    /// Platform is not supported by the permission set.
9    #[error(
10        code = "PLATFORM_NOT_SUPPORTED",
11        message = "Platform '{platform}' is not supported by permission set '{permission_set_id}'",
12        retryable = "false",
13        internal = "false"
14    )]
15    PlatformNotSupported {
16        /// The unsupported platform name
17        platform: String,
18        /// ID of the permission set that doesn't support this platform
19        permission_set_id: String,
20    },
21
22    /// Binding target is not supported by the platform.
23    #[error(
24        code = "BINDING_TARGET_NOT_SUPPORTED",
25        message = "Binding target '{binding_target}' is not supported by platform '{platform}' in permission set '{permission_set_id}'",
26        retryable = "false",
27        internal = "false"
28    )]
29    BindingTargetNotSupported {
30        /// The platform that doesn't support this binding target
31        platform: String,
32        /// The unsupported binding target type
33        binding_target: String,
34        /// ID of the permission set
35        permission_set_id: String,
36    },
37
38    /// Required variable not found in permission context.
39    #[error(
40        code = "VARIABLE_NOT_FOUND",
41        message = "Variable '{variable}' is not found in permission context",
42        retryable = "false",
43        internal = "false"
44    )]
45    VariableNotFound {
46        /// Name of the missing variable
47        variable: String,
48    },
49
50    /// Permission set format is invalid.
51    #[error(
52        code = "INVALID_PERMISSION_SET",
53        message = "Invalid permission set format: {message}",
54        retryable = "false",
55        internal = "true"
56    )]
57    InvalidPermissionSet {
58        /// Human-readable description of the format issue
59        message: String,
60    },
61
62    /// Permission generator failed for the specified platform.
63    #[error(
64        code = "GENERATOR_ERROR",
65        message = "Generator error for platform '{platform}': {message}",
66        retryable = "false",
67        internal = "true"
68    )]
69    GeneratorError {
70        /// The platform where generation failed
71        platform: String,
72        /// Human-readable description of the generation failure
73        message: String,
74    },
75
76    /// Serialization or deserialization of permission data failed.
77    #[error(
78        code = "SERIALIZATION_ERROR",
79        message = "Serialization error: {message}",
80        retryable = "false",
81        internal = "true"
82    )]
83    SerializationError {
84        /// Human-readable description of the serialization failure
85        message: String,
86    },
87
88    /// Permission file I/O operation failed.
89    #[error(
90        code = "PERMISSION_FILE_IO_ERROR",
91        message = "Permission file I/O operation failed on '{path}': {message}",
92        retryable = "true",
93        internal = "false"
94    )]
95    PermissionFileIoError {
96        /// Path to the file that failed
97        path: String,
98        /// Human-readable description of the I/O failure
99        message: String,
100    },
101
102    /// Generic permission error for uncommon cases.
103    #[error(
104        code = "PERMISSION_ERROR",
105        message = "Permission operation failed: {message}",
106        retryable = "false",
107        internal = "true"
108    )]
109    Other {
110        /// Human-readable description of the error
111        message: String,
112    },
113}
114
115pub type Result<T> = alien_error::Result<T, ErrorData>;