Skip to content

Commit 1d898d2

Browse files
committed
refactor: Reorganize errors by alphabetical order
1 parent 2bc7cb0 commit 1d898d2

File tree

8 files changed

+65
-64
lines changed

8 files changed

+65
-64
lines changed

src/application_credential/error.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@ pub enum ApplicationCredentialProviderError {
3030
#[error("conflict: {0}")]
3131
Conflict(String),
3232

33+
/// Unsupported driver.
34+
#[error("unsupported driver {0}")]
35+
UnsupportedDriver(String),
36+
3337
/// Request validation error.
3438
#[error("request validation error: {}", source)]
3539
Validation {
3640
/// The source of the error.
3741
#[from]
3842
source: validator::ValidationErrors,
3943
},
40-
41-
/// Unsupported driver.
42-
#[error("unsupported driver {0}")]
43-
UnsupportedDriver(String),
4444
}
4545

4646
impl From<ApplicationCredentialDatabaseError> for ApplicationCredentialProviderError {

src/error.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -194,15 +194,6 @@ pub enum DatabaseError {
194194
context: String,
195195
},
196196

197-
/// SqlError.
198-
#[error("{message} while {context}")]
199-
Sql {
200-
/// The error message.
201-
message: String,
202-
/// The error context.
203-
context: String,
204-
},
205-
206197
/// Database error.
207198
#[error("Database error while {context}")]
208199
Database {
@@ -211,6 +202,15 @@ pub enum DatabaseError {
211202
/// The error context.
212203
context: String,
213204
},
205+
206+
/// SqlError.
207+
#[error("{message} while {context}")]
208+
Sql {
209+
/// The error message.
210+
message: String,
211+
/// The error context.
212+
context: String,
213+
},
214214
}
215215

216216
pub trait DbContextExt<T> {

src/identity/backend/error.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ pub enum IdentityDatabaseError {
3939
#[error("{0}")]
4040
GroupNotFound(String),
4141

42-
#[error("corrupted database entries for user {0}")]
43-
MalformedUser(String),
44-
4542
#[error(transparent)]
4643
Join {
4744
#[from]
4845
source: tokio::task::JoinError,
4946
},
5047

48+
#[error("corrupted database entries for user {0}")]
49+
MalformedUser(String),
50+
5151
/// No data for local_user and passwords
5252
#[error("no passwords for the user {0}")]
5353
NoPasswordsForUser(String),

src/identity/error.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,6 @@ pub enum IdentityProviderError {
7373
source: BuilderError,
7474
},
7575

76-
/// Request validation error.
77-
#[error("request validation error: {}", source)]
78-
Validation {
79-
/// The source of the error.
80-
#[from]
81-
source: validator::ValidationErrors,
82-
},
83-
8476
/// Unsupported driver.
8577
#[error("unsupported driver {0}")]
8678
UnsupportedDriver(String),
@@ -92,6 +84,13 @@ pub enum IdentityProviderError {
9284
/// The user has not been found.
9385
#[error("user {0} not found")]
9486
UserNotFound(String),
87+
/// Request validation error.
88+
#[error("request validation error: {}", source)]
89+
Validation {
90+
/// The source of the error.
91+
#[from]
92+
source: validator::ValidationErrors,
93+
},
9594
}
9695

9796
impl From<IdentityDatabaseError> for IdentityProviderError {

src/identity_mapping/error.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,17 @@ pub enum IdentityMappingError {
4747
source: BuilderError,
4848
},
4949

50+
/// Unsupported driver.
51+
#[error("unsupported driver {0}")]
52+
UnsupportedDriver(String),
53+
5054
/// Request validation error.
5155
#[error("request validation error: {}", source)]
5256
Validation {
5357
/// The source of the error.
5458
#[from]
5559
source: validator::ValidationErrors,
5660
},
57-
58-
/// Unsupported driver.
59-
#[error("unsupported driver {0}")]
60-
UnsupportedDriver(String),
6161
}
6262

6363
impl From<IdentityMappingDatabaseError> for IdentityMappingError {

src/policy.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,18 @@ use crate::token::Token;
4040
/// Policy related error.
4141
#[derive(Debug, Error)]
4242
pub enum PolicyError {
43+
/// Module compilation error.
44+
#[error("module compilation task crashed")]
45+
Compilation(#[from] eyre::Report),
46+
47+
/// Forbidden error.
4348
#[error("{}", .0.violations.as_ref().map(
4449
|v| v.iter().cloned().map(|x| x.msg)
4550
.reduce(|acc, s| format!("{acc}, {s}"))
4651
.unwrap_or_default()
4752
).unwrap_or("The request you made requires authentication.".into()))]
4853
Forbidden(PolicyEvaluationResult),
4954

50-
#[error("module compilation task crashed")]
51-
Compilation(#[from] eyre::Report),
52-
5355
#[error(transparent)]
5456
IO(#[from] std::io::Error),
5557

src/token/error.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ pub enum TokenProviderError {
2626
#[error("actor has no roles on scope")]
2727
ActorHasNoRolesOnTarget,
2828

29-
/// Application Credential used in the token is not found.
30-
#[error("application credential with id: {0} not found")]
31-
ApplicationCredentialNotFound(String),
32-
3329
/// Application Credential has expired.
3430
#[error("application credential has expired")]
3531
ApplicationCredentialExpired,
3632

33+
/// Application Credential used in the token is not found.
34+
#[error("application credential with id: {0} not found")]
35+
ApplicationCredentialNotFound(String),
36+
3737
/// Application credential provider error.
3838
#[error(transparent)]
3939
ApplicationCredentialProvider {
@@ -86,6 +86,14 @@ pub enum TokenProviderError {
8686
#[error("federated payload must contain idp_id and protocol_id")]
8787
FederatedPayloadMissingData,
8888

89+
/// Fernet Decryption
90+
#[error("fernet decryption error")]
91+
FernetDecryption(#[from] fernet::DecryptionError),
92+
93+
/// Missing fernet keys
94+
#[error("no usable fernet keys has been found")]
95+
FernetKeysMissing,
96+
8997
/// Fernet key read error.
9098
#[error("fernet key read error: {}", source)]
9199
FernetKeyRead {
@@ -95,14 +103,6 @@ pub enum TokenProviderError {
95103
path: std::path::PathBuf,
96104
},
97105

98-
/// Fernet Decryption
99-
#[error("fernet decryption error")]
100-
FernetDecryption(#[from] fernet::DecryptionError),
101-
102-
/// Missing fernet keys
103-
#[error("no usable fernet keys has been found")]
104-
FernetKeysMissing,
105-
106106
#[error(transparent)]
107107
IdentityProvider(#[from] crate::identity::error::IdentityProviderError),
108108

@@ -157,14 +157,14 @@ pub enum TokenProviderError {
157157
#[error(transparent)]
158158
RevokeProvider(#[from] crate::revoke::error::RevokeProviderError),
159159

160-
/// MSGPack Decryption
161-
#[error("rmp value error")]
162-
RmpValueRead(#[from] rmp::decode::ValueReadError),
163-
164160
/// MSGPack Encryption
165161
#[error("rmp value encoding error")]
166162
RmpEncode(String),
167163

164+
/// MSGPack Decryption
165+
#[error("rmp value error")]
166+
RmpValueRead(#[from] rmp::decode::ValueReadError),
167+
168168
/// Target scope information is not found in the token.
169169
#[error("scope information missing")]
170170
ScopeMissing,
@@ -193,23 +193,23 @@ pub enum TokenProviderError {
193193
#[error("token has been revoked")]
194194
TokenRevoked,
195195

196-
#[error("int parse")]
197-
TryFromIntError(#[from] TryFromIntError),
198-
199196
/// Trust provider error.
200197
#[error(transparent)]
201198
TrustProvider(#[from] crate::trust::TrustError),
202199

200+
#[error("int parse")]
201+
TryFromIntError(#[from] TryFromIntError),
202+
203+
#[error("unsupported authentication methods {0} in token payload")]
204+
UnsupportedAuthMethods(String),
205+
203206
/// The user is disabled.
204207
#[error("user disabled")]
205208
UserDisabled(String),
206209

207210
#[error("user cannot be found: {0}")]
208211
UserNotFound(String),
209212

210-
#[error("unsupported authentication methods {0} in token payload")]
211-
UnsupportedAuthMethods(String),
212-
213213
#[error("uuid decryption error")]
214214
Uuid(#[from] uuid::Error),
215215

src/trust/error.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,28 +42,28 @@ pub enum TrustError {
4242
#[error("requested expiration is more than the redelegated trust can provide")]
4343
ExpirationImpossible,
4444

45-
/// Redelegation chain is longer than allowed.
46-
#[error("redelegation depth of {length} is out of allowed range [0..{max_depth}]")]
47-
RedelegationDeepnessExceed { length: usize, max_depth: usize },
48-
49-
/// Relegation trust must not add new roles.
50-
#[error("some of the requested roles are not in the redelegated trust")]
51-
RedelegatedRolesNotAvailable,
52-
5345
/// Relegated trust does not allow impersonation.
5446
#[error(
5547
"impersonation is not allowed because redelegated trust does not specify impersonation"
5648
)]
5749
RedelegatedImpersonationNotAllowed,
5850

59-
/// Remaining uses must be unset to redelegate a trust.
60-
#[error("remaining uses is set while it must not be set in order to redelegate a trust")]
61-
RemainingUsesMustBeUnset,
51+
/// Relegation trust must not add new roles.
52+
#[error("some of the requested roles are not in the redelegated trust")]
53+
RedelegatedRolesNotAvailable,
54+
55+
/// Redelegation chain is longer than allowed.
56+
#[error("redelegation depth of {length} is out of allowed range [0..{max_depth}]")]
57+
RedelegationDeepnessExceed { length: usize, max_depth: usize },
6258

6359
/// Remaining uses of the trust is exceeded.
6460
#[error("remaining uses exceed")]
6561
RemainingUsesExceed,
6662

63+
/// Remaining uses must be unset to redelegate a trust.
64+
#[error("remaining uses is set while it must not be set in order to redelegate a trust")]
65+
RemainingUsesMustBeUnset,
66+
6767
/// (de)serialization error.
6868
#[error(transparent)]
6969
Serde {

0 commit comments

Comments
 (0)