api: add structured context for service errors

This commit is contained in:
a.tolmachev
2026-04-19 21:45:26 +00:00
parent 37bc3c4e2b
commit ba10bf805d
3 changed files with 197 additions and 24 deletions
+3 -3
View File
@@ -90,21 +90,21 @@ impl ApiError {
}
}
fn validation_with_context(message: impl Into<String>, context: Value) -> Self {
pub(crate) fn validation_with_context(message: impl Into<String>, context: Value) -> Self {
Self::Validation {
message: message.into(),
context: Some(context),
}
}
fn not_found_with_context(message: impl Into<String>, context: Value) -> Self {
pub(crate) fn not_found_with_context(message: impl Into<String>, context: Value) -> Self {
Self::NotFound {
message: message.into(),
context: Some(context),
}
}
fn conflict_with_context(message: impl Into<String>, context: Value) -> Self {
pub(crate) fn conflict_with_context(message: impl Into<String>, context: Value) -> Self {
Self::Conflict {
message: message.into(),
context: Some(context),