feat: add unique constraint restriction for KV (#3723)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Kartikeya Hegde
2024-02-26 13:37:05 +00:00
committed by GitHub
parent 9aabb14a60
commit c117f8ec63
6 changed files with 126 additions and 10 deletions

View File

@ -165,10 +165,12 @@ impl RedisErrorExt for error_stack::Report<RedisError> {
RedisError::NotFound => self.change_context(DataStorageError::ValueNotFound(format!(
"Data does not exist for key {key}",
))),
RedisError::SetNxFailed => self.change_context(DataStorageError::DuplicateValue {
entity: "redis",
key: Some(key.to_string()),
}),
RedisError::SetNxFailed | RedisError::SetAddMembersFailed => {
self.change_context(DataStorageError::DuplicateValue {
entity: "redis",
key: Some(key.to_string()),
})
}
_ => self.change_context(DataStorageError::KVError),
}
}