#[non_exhaustive]pub enum Error {
Http(Error),
Serialization(Error),
Config(PortkeyBuilderError),
UrlParse(ParseError),
}Expand description
Error type for Portkey API operations.
This enum represents all possible errors that can occur when using the Portkey SDK, from HTTP transport errors to API-specific failures and configuration issues.
§Examples
Handling different error types:
use portkey_sdk::{Error, Result, PortkeyClient};
use portkey_sdk::service::ModelsService;
let client: PortkeyClient = PortkeyClient::from_env()?;
// Example error handling
match client.list_models(None).await {
Ok(models) => println!("Found {} models", models.data.len()),
Err(Error::Http(e)) => println!("Network error: {}", e),
Err(Error::Config(e)) => println!("Configuration error: {}", e),
Err(e) => println!("Other error: {}", e),
}Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Http(Error)
HTTP transport error from the underlying HTTP client.
This includes network connectivity issues, DNS resolution failures, timeout errors, and other transport-layer problems.
Serialization(Error)
JSON serialization/deserialization error.
This occurs when the SDK fails to parse API responses or serialize request payloads to/from JSON.
Config(PortkeyBuilderError)
Configuration error.
This occurs when configuration parameters are invalid or when using the configuration builder and validation fails during the build process.
UrlParse(ParseError)
URL parsing error.
This occurs when a provided URL string is invalid or cannot be parsed.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
Source§impl From<ParseError> for Error
impl From<ParseError> for Error
Source§fn from(source: ParseError) -> Self
fn from(source: ParseError) -> Self
Source§impl From<PortkeyBuilderError> for Error
impl From<PortkeyBuilderError> for Error
Source§fn from(source: PortkeyBuilderError) -> Self
fn from(source: PortkeyBuilderError) -> Self
Auto Trait Implementations§
impl Freeze for Error
impl !RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl !UnwindSafe for Error
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> 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> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.