LSystemError

Enum LSystemError 

Source
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

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for LSystemError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for LSystemError

1.30.0 · Source§

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

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.