pub enum LSystemError {
DivideByZero,
InvalidFloat,
NoBoundingBox,
FileSystemError(Box<dyn Error>),
DeserializationError(Box<dyn Error>),
}Expand description
Combined error type for the crate.
Variants§
DivideByZero
Indicates division by zero attempted.
§Example
use std::collections::HashMap;
use l_system_fractals::rules::DrawRules;
let dr = DrawRules::new_simple(
HashMap::from([('A', "A-A+A-A".into())]),
1,
0 // denominator of a fraction
);
assert!(dr.is_err());
let err_msg = format!("{:?}", dr);
assert!(err_msg.contains("DivideByZero"));InvalidFloat
Indicates a float that is NaN or ±∞.
These do not make sense in the context of SVG coordinates.
This error is raised by, e.g., crate::num_validity::err_if_invalid.
§Example
use l_system_fractals::num_validity::err_if_invalid;
let x = err_if_invalid(f64::NAN);
let err_msg = format!("{:?}", x);
assert!(err_msg.contains("InvalidFloat"));NoBoundingBox
Indicates that no bounding box could be computed in a context where it is required.
This error is raised by, e.g., crate::paths::Path::bounding_box.
§Example
use l_system_fractals::paths::{Path, Point};
let empty_vec: Vec<Point> = vec![];
let empty_path = Path::from(empty_vec);
let bb = empty_path.bounding_box();
let err_msg = format!("{:?}", bb);
assert!(err_msg.contains("NoBoundingBox"));FileSystemError(Box<dyn Error>)
Indicates a file system error (e.g. incorrect file name).
DeserializationError(Box<dyn Error>)
Indicates a problem in the deserialization process (e.g. malformed JSON).
Trait Implementations§
Source§impl Debug for LSystemError
impl Debug for LSystemError
Source§impl Display for LSystemError
impl Display for LSystemError
Source§impl Error for LSystemError
impl Error for LSystemError
1.30.0 · 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 LSystemError
impl !RefUnwindSafe for LSystemError
impl !Send for LSystemError
impl !Sync for LSystemError
impl Unpin for LSystemError
impl !UnwindSafe for LSystemError
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