Skip to main content

objectiveai_sdk/error/
http.rs

1//! HTTP client functions for the error endpoint.
2use crate::{HttpClient, HttpError, McpHandler, Notifier};
3use futures::Stream;
4
5/// Creates an error response (unary).
6pub async fn create_error_unary(
7    client: &HttpClient,
8    mut params: super::request::ErrorCreateParams,
9) -> Result<super::response::ErrorResponse, HttpError> {
10    params.stream = None;
11    client
12        .send_unary(reqwest::Method::POST, "error", Some(params))
13        .await
14}
15
16/// Creates an error response with streaming. Returns
17/// `(Stream<Chunk>, Notifier)`; see
18/// [`crate::agent::completions::http::create_agent_completion_streaming`]
19/// for the demux + handler semantics.
20pub async fn create_error_streaming<H: McpHandler>(
21    client: &HttpClient,
22    mut params: super::request::ErrorCreateParams,
23    handler: H,
24) -> Result<
25    (
26        impl Stream<Item = Result<super::response::ErrorResponse, HttpError>>
27        + Send
28        + Unpin
29        + 'static
30        + use<H>,
31        Notifier,
32    ),
33    HttpError,
34> {
35    params.stream = Some(true);
36    client
37        .send_streaming_ws(reqwest::Method::POST, "error", params, handler)
38        .await
39}