Skip to content

Commit d7be1fb

Browse files
committed
fix(api): return json error response for deletion of entry in set
1 parent 73173b2 commit d7be1fb

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

couic/src/api/policies.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ use crate::{
1515
middleware::auth_middleware,
1616
rbac::{Resource, Scope, Verb},
1717
},
18+
error::CompositeError,
1819
extractors::ValidatedJson,
1920
};
20-
use common::{Action, Client, PeerJob, Policy, PolicyPath, RawEntry};
21+
use common::{Action, Client, ErrorCode, PeerJob, Policy, PolicyPath, RawEntry};
2122

2223
/// List all entries based on policy
2324
async fn list_entries(
@@ -91,11 +92,11 @@ async fn delete_entry(
9192
"failed to delete entry: policy={}, cidr={} is in a set",
9293
policy_path.policy, policy_path.cidr
9394
);
94-
return (
95-
StatusCode::UNPROCESSABLE_ENTITY,
95+
return CompositeError::new(
96+
ErrorCode::Econflict,
9697
"Entry defined in a set cannot be removed",
9798
)
98-
.into_response();
99+
.into_response();
99100
}
100101

101102
match state

0 commit comments

Comments
 (0)