pub struct ErrorResponder;Expand description
Helper struct for emitting error responses with consistent formatting and metadata
Implementations§
Source§impl ErrorResponder
impl ErrorResponder
Sourcepub fn emit(
error: ErrorDetails,
output_format: OutputFormat,
meta: Option<HashMap<String, Value>>,
exit_code: ExitCode,
) -> !
pub fn emit( error: ErrorDetails, output_format: OutputFormat, meta: Option<HashMap<String, Value>>, exit_code: ExitCode, ) -> !
Emit an error response and exit with the appropriate exit code
This centralizes error response generation by:
- Creating an error envelope with optional metadata
- Printing the response in the specified format
- Exiting with the appropriate exit code
Sourcepub fn create_meta(trace_id: Option<&String>) -> Option<HashMap<String, Value>>
pub fn create_meta(trace_id: Option<&String>) -> Option<HashMap<String, Value>>
Create metadata map from trace_id if present
Sourcepub fn error(code: ErrorCode, message: impl Into<String>) -> ErrorDetails
pub fn error(code: ErrorCode, message: impl Into<String>) -> ErrorDetails
Create a simple error with code and message
Sourcepub fn error_with_retry(
code: ErrorCode,
message: impl Into<String>,
retry_after_ms: u64,
) -> ErrorDetails
pub fn error_with_retry( code: ErrorCode, message: impl Into<String>, retry_after_ms: u64, ) -> ErrorDetails
Create an error with retry_after_ms
Sourcepub fn error_with_details(
code: ErrorCode,
message: impl Into<String>,
details: HashMap<String, Value>,
) -> ErrorDetails
pub fn error_with_details( code: ErrorCode, message: impl Into<String>, details: HashMap<String, Value>, ) -> ErrorDetails
Create an error with additional details
Sourcepub fn auth_required_error(
message: impl Into<String>,
next_steps: Vec<String>,
) -> ErrorDetails
pub fn auth_required_error( message: impl Into<String>, next_steps: Vec<String>, ) -> ErrorDetails
Create an auth required error with next steps
Auto Trait Implementations§
impl Freeze for ErrorResponder
impl RefUnwindSafe for ErrorResponder
impl Send for ErrorResponder
impl Sync for ErrorResponder
impl Unpin for ErrorResponder
impl UnsafeUnpin for ErrorResponder
impl UnwindSafe for ErrorResponder
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