Skip to main content

systemprompt_models/api/
ext.rs

1//! `ApiErrorExt`: stamping request-context identifiers onto API errors.
2//!
3//! Copyright (c) systemprompt.io — Business Source License 1.1.
4//! See <https://systemprompt.io> for licensing details.
5
6use super::ApiError;
7use crate::execution::context::RequestContext;
8
9pub trait ApiErrorExt {
10    fn with_request_context(self, ctx: &RequestContext) -> Self;
11}
12
13impl ApiErrorExt for ApiError {
14    fn with_request_context(self, ctx: &RequestContext) -> Self {
15        self.with_trace_id(ctx.trace_id().to_string())
16    }
17}