#[non_exhaustive]pub enum JsonToolsError {
JsonParseError {
message: String,
suggestion: String,
source: JsonError,
},
RegexError {
message: String,
suggestion: String,
source: Error,
},
InvalidReplacementPattern {
message: String,
suggestion: String,
},
InvalidJsonStructure {
message: String,
suggestion: String,
},
ConfigurationError {
message: String,
suggestion: String,
},
BatchProcessingError {
index: usize,
message: String,
suggestion: String,
source: Box<JsonToolsError>,
},
InputValidationError {
message: String,
suggestion: String,
},
SerializationError {
message: String,
suggestion: String,
source: JsonError,
},
}Expand description
Comprehensive error type for all JSON Tools operations with detailed information and suggestions
Each error variant includes:
- Machine-readable error code (E001-E008) for programmatic handling
- Human-readable message
- Actionable suggestion
- Source error (where applicable)
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
JsonParseError
Error parsing JSON input with detailed context and suggestions
RegexError
Error compiling or using regex patterns with helpful suggestions
InvalidReplacementPattern
Invalid replacement pattern configuration with detailed guidance
InvalidJsonStructure
Invalid JSON structure for the requested operation
ConfigurationError
Configuration error when operation mode is not set
BatchProcessingError
Error processing batch item with detailed context
InputValidationError
Input validation error with helpful guidance
SerializationError
Serialization error when converting results back to JSON
Implementations§
Source§impl JsonToolsError
impl JsonToolsError
Sourcepub fn error_code(&self) -> &'static str
pub fn error_code(&self) -> &'static str
Get machine-readable error code for programmatic handling
§Examples
use json_tools_rs::{JSONTools, JsonToolsError};
let result = JSONTools::new().flatten().execute("invalid json");
if let Err(e) = result {
match e.error_code() {
"E001" => println!("JSON parsing error"),
"E005" => println!("Configuration error"),
_ => println!("Other error"),
}
}Sourcepub fn json_parse_error(source: JsonError) -> Self
pub fn json_parse_error(source: JsonError) -> Self
Create a JSON parse error with helpful suggestions
Sourcepub fn regex_error(source: Error) -> Self
pub fn regex_error(source: Error) -> Self
Create a regex error with helpful suggestions
Sourcepub fn invalid_replacement_pattern(message: impl Into<String>) -> Self
pub fn invalid_replacement_pattern(message: impl Into<String>) -> Self
Create an invalid replacement pattern error
Sourcepub fn invalid_json_structure(message: impl Into<String>) -> Self
pub fn invalid_json_structure(message: impl Into<String>) -> Self
Create an invalid JSON structure error
Sourcepub fn configuration_error(message: impl Into<String>) -> Self
pub fn configuration_error(message: impl Into<String>) -> Self
Create a configuration error
Sourcepub fn batch_processing_error(index: usize, source: JsonToolsError) -> Self
pub fn batch_processing_error(index: usize, source: JsonToolsError) -> Self
Create a batch processing error
Sourcepub fn input_validation_error(message: impl Into<String>) -> Self
pub fn input_validation_error(message: impl Into<String>) -> Self
Create an input validation error
Sourcepub fn serialization_error(source: JsonError) -> Self
pub fn serialization_error(source: JsonError) -> Self
Create a serialization error
Trait Implementations§
Source§impl Debug for JsonToolsError
impl Debug for JsonToolsError
Source§impl Display for JsonToolsError
impl Display for JsonToolsError
Source§impl Error for JsonToolsError
impl Error for JsonToolsError
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
use the Display impl or to_string()
Source§impl From<Error> for JsonToolsError
impl From<Error> for JsonToolsError
Auto Trait Implementations§
impl !RefUnwindSafe for JsonToolsError
impl !UnwindSafe for JsonToolsError
impl Freeze for JsonToolsError
impl Send for JsonToolsError
impl Sync for JsonToolsError
impl Unpin for JsonToolsError
impl UnsafeUnpin for JsonToolsError
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> 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