pub struct OpenAiError {
pub error: OpenAiErrorBody,
}Expand description
Top-level OpenAI error envelope: { "error": { ... } }.
Fields§
§error: OpenAiErrorBodyInner error body.
Implementations§
Source§impl OpenAiError
impl OpenAiError
Sourcepub fn not_yet_wired(message: impl Into<String>) -> Self
pub fn not_yet_wired(message: impl Into<String>) -> Self
Construct a not-implemented envelope. Used by both scaffold handlers to keep the wire output identical.
Sourcepub fn invalid_request(
message: impl Into<String>,
param: Option<String>,
) -> Self
pub fn invalid_request( message: impl Into<String>, param: Option<String>, ) -> Self
Construct an invalid_request_error envelope for malformed input.
param should name the field that triggered the error, if known.
Sourcepub fn with_code(self, code: &'static str) -> Self
pub fn with_code(self, code: &'static str) -> Self
Override the machine-readable code on an existing envelope.
Used by the translator to stamp a more specific code
(e.g. unsupported_parameter) onto an invalid_request envelope
while keeping its type / param / status mapping intact — an
invalid_request_error with any code other than model_not_found
still maps to 400 in OpenAiError::into_response.
Sourcepub fn model_not_found(message: impl Into<String>) -> Self
pub fn model_not_found(message: impl Into<String>) -> Self
Construct a model_not_found envelope for an unknown model id.
Mirrors the OpenAI 404 model_not_found response shape so SDKs
surface a clean “this model is not available on this endpoint”
error to the caller. param is fixed to Some("model") —
every model_not_found is caused by the same field.
Sourcepub fn server_error(message: impl Into<String>, code: &'static str) -> Self
pub fn server_error(message: impl Into<String>, code: &'static str) -> Self
Construct a generic server-side internal envelope.
Used when guest execution fails in a way that doesn’t map to a
caller-correctable category (e.g. a wasm trap, an executor
configuration error). The OpenAI type is set to
server_error and code to wasm_error so callers can branch
on either the OpenAI-conventional category or the
implementation-specific code.
Sourcepub fn tenant_scope_denied(message: impl Into<String>) -> Self
pub fn tenant_scope_denied(message: impl Into<String>) -> Self
Construct a 403 tenant_scope_denied envelope.
Mirrors the native invoke handlers’ per-resource owner check
(routes.rs, e.g. FunctionRecord::tenant_id != tenant →
ApiError::forbidden with
kind = "tenant_scope_denied"): a wildcard-scoped caller from
tenant B must not drive a model that resolves to tenant A’s
function. The OpenAI type is invalid_request_error (OpenAI has
no dedicated authorization category) with code = "tenant_scope_denied",
which OpenAiError::into_response maps to 403.
Trait Implementations§
Source§impl Clone for OpenAiError
impl Clone for OpenAiError
Source§fn clone(&self) -> OpenAiError
fn clone(&self) -> OpenAiError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for OpenAiError
impl Debug for OpenAiError
Source§impl<'de> Deserialize<'de> for OpenAiError
impl<'de> Deserialize<'de> for OpenAiError
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl IntoResponse for OpenAiError
impl IntoResponse for OpenAiError
Source§fn into_response(self) -> Response
fn into_response(self) -> Response
Auto Trait Implementations§
impl Freeze for OpenAiError
impl RefUnwindSafe for OpenAiError
impl Send for OpenAiError
impl Sync for OpenAiError
impl Unpin for OpenAiError
impl UnsafeUnpin for OpenAiError
impl UnwindSafe for OpenAiError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T, S> Handler<IntoResponseHandler, S> for T
impl<T, S> Handler<IntoResponseHandler, S> for T
Source§fn call(
self,
_req: Request<Body>,
_state: S,
) -> <T as Handler<IntoResponseHandler, S>>::Future
fn call( self, _req: Request<Body>, _state: S, ) -> <T as Handler<IntoResponseHandler, S>>::Future
Source§fn layer<L>(self, layer: L) -> Layered<L, Self, T, S>where
L: Layer<HandlerService<Self, T, S>> + Clone,
<L as Layer<HandlerService<Self, T, S>>>::Service: Service<Request<Body>>,
fn layer<L>(self, layer: L) -> Layered<L, Self, T, S>where
L: Layer<HandlerService<Self, T, S>> + Clone,
<L as Layer<HandlerService<Self, T, S>>>::Service: Service<Request<Body>>,
tower::Layer to the handler. Read moreSource§fn with_state(self, state: S) -> HandlerService<Self, T, S>
fn with_state(self, state: S) -> HandlerService<Self, T, S>
Service by providing the stateSource§impl<H, T> HandlerWithoutStateExt<T> for H
impl<H, T> HandlerWithoutStateExt<T> for H
Source§fn into_service(self) -> HandlerService<H, T, ()>
fn into_service(self) -> HandlerService<H, T, ()>
Service and no state.Source§fn into_make_service(self) -> IntoMakeService<HandlerService<H, T, ()>>
fn into_make_service(self) -> IntoMakeService<HandlerService<H, T, ()>>
MakeService and no state. Read moreSource§fn into_make_service_with_connect_info<C>(
self,
) -> IntoMakeServiceWithConnectInfo<HandlerService<H, T, ()>, C>
fn into_make_service_with_connect_info<C>( self, ) -> IntoMakeServiceWithConnectInfo<HandlerService<H, T, ()>, C>
MakeService which stores information
about the incoming connection and has no state. Read moreimpl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more