pub enum Error {
Show 15 variants
ServerAlreadyStarted(u16),
ServerNotStarted,
PortInUse(u16),
PortDiscoveryFailed(String),
InvalidConfig(String),
InvalidStub(String),
StubNotFound {
method: String,
path: String,
available: String,
},
Http(Error),
Io(Error),
Json(Error),
Core(Error),
StartupTimeout {
timeout_secs: u64,
},
ShutdownTimeout {
timeout_secs: u64,
},
AdminApiError {
operation: String,
message: String,
endpoint: String,
},
General(String),
}Expand description
SDK Error types
Variants§
ServerAlreadyStarted(u16)
Server already started
ServerNotStarted
Server not started
PortInUse(u16)
Port already in use
PortDiscoveryFailed(String)
Port discovery failed
InvalidConfig(String)
Invalid configuration
InvalidStub(String)
Invalid stub
StubNotFound
Stub not found
Fields
Http(Error)
HTTP error
Io(Error)
IO error
Json(Error)
JSON serialization error
Core(Error)
MockForge core error
StartupTimeout
Server startup timeout
ShutdownTimeout
Server shutdown timeout
AdminApiError
Admin API error
Fields
General(String)
General error
Implementations§
Source§impl Error
impl Error
Sourcepub fn admin_api_error(
operation: impl Into<String>,
message: impl Into<String>,
endpoint: impl Into<String>,
) -> Self
pub fn admin_api_error( operation: impl Into<String>, message: impl Into<String>, endpoint: impl Into<String>, ) -> Self
Create an admin API error with context
§Examples
use mockforge_sdk::Error;
let err = Error::admin_api_error(
"create_mock",
"Invalid JSON",
"/api/mocks"
);Sourcepub fn stub_not_found(
method: impl Into<String>,
path: impl Into<String>,
available: Vec<String>,
) -> Self
pub fn stub_not_found( method: impl Into<String>, path: impl Into<String>, available: Vec<String>, ) -> Self
Create a stub not found error with available stubs
§Examples
use mockforge_sdk::Error;
let err = Error::stub_not_found(
"GET",
"/api/missing",
vec!["GET /api/users".to_string()]
);Sourcepub fn to_log_string(&self) -> String
pub fn to_log_string(&self) -> String
Format error for logging (single line, no ANSI colors)
Useful for structured logging where multi-line messages aren’t desired.
§Examples
use mockforge_sdk::Error;
let err = Error::ServerNotStarted;
let log_msg = err.to_log_string();
// Use in logging: log::error!("{}", log_msg);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)>
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()
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
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> Pointable for T
impl<T> Pointable for T
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.