pub enum OpencodeError {
Show 13 variants
Http {
status: u16,
name: Option<String>,
message: String,
data: Option<Value>,
},
Network(String),
Sse(String),
Json(Error),
Url(ParseError),
SpawnServer {
message: String,
},
ServerTimeout {
timeout_ms: u64,
},
Process(String),
InvalidConfig(String),
Io(Error),
StreamClosed,
SessionNotFound(String),
State(String),
}Expand description
Error type for opencode_rs operations.
Variants§
Http
HTTP error with structured response from OpenCode.
Fields
Network(String)
Network/connection error.
Sse(String)
SSE streaming error.
Json(Error)
JSON serialization/deserialization error.
Url(ParseError)
URL parsing error.
SpawnServer
Failed to spawn server process.
ServerTimeout
Server not ready within timeout.
Process(String)
Process execution error.
InvalidConfig(String)
Invalid configuration.
Io(Error)
IO error.
StreamClosed
Stream closed unexpectedly.
SessionNotFound(String)
Session not found.
State(String)
Internal state error.
Implementations§
Source§impl OpencodeError
impl OpencodeError
Sourcepub fn http(status: u16, body_text: &str) -> Self
pub fn http(status: u16, body_text: &str) -> Self
Create an HTTP error from status and optional JSON body.
Sourcepub fn is_not_found(&self) -> bool
pub fn is_not_found(&self) -> bool
Check if this is a “not found” error (404).
Sourcepub fn is_validation_error(&self) -> bool
pub fn is_validation_error(&self) -> bool
Check if this is a validation error (400).
Sourcepub fn is_server_error(&self) -> bool
pub fn is_server_error(&self) -> bool
Check if this is a server error (5xx).
Sourcepub fn error_name(&self) -> Option<&str>
pub fn error_name(&self) -> Option<&str>
Get the error name if this is an HTTP error.
Trait Implementations§
Source§impl Debug for OpencodeError
impl Debug for OpencodeError
Source§impl Display for OpencodeError
impl Display for OpencodeError
Source§impl Error for OpencodeError
impl Error for OpencodeError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Source§impl From<Error> for OpencodeError
impl From<Error> for OpencodeError
Source§impl From<Error> for OpencodeError
impl From<Error> for OpencodeError
Source§impl From<ParseError> for OpencodeError
impl From<ParseError> for OpencodeError
Source§fn from(source: ParseError) -> Self
fn from(source: ParseError) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for OpencodeError
impl !RefUnwindSafe for OpencodeError
impl Send for OpencodeError
impl Sync for OpencodeError
impl Unpin for OpencodeError
impl !UnwindSafe for OpencodeError
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
Mutably borrows from an owned value. Read more
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.