TheError

Struct TheError 

Source
pub struct TheError {
    pub error: TheErrorType,
    pub file: Option<String>,
    pub location: Option<(u32, u32)>,
    pub datestamp: Option<NaiveDate>,
    pub timestamp: Option<NaiveTime>,
}
Expand description

Struct that contains the error itself mapped within a TheErrorType struct, with its error content configured in the origin crate, the file, location, datestamp and timestamp data of when the error was remapped using the map_to_new_error! macro.

Fields§

§error: TheErrorType§file: Option<String>§location: Option<(u32, u32)>§datestamp: Option<NaiveDate>§timestamp: Option<NaiveTime>

Implementations§

Source§

impl TheError

Source

pub fn new(error_type: SystemErrorCodes, error_content: String) -> Self

Description: Creates a new error of TheError type, receiving as parameters the error type and content, and capturing the file, location, datestamp and timestamp info

Source

pub fn get_type(&self) -> &SystemErrorCodes

Returns the SystemErrorCode associated with this error

Source

pub fn get_content(&self) -> &String

Returns the error content mapped from the origin error

Source

pub fn get_location_info(&self) -> &Option<(u32, u32)>

Returns the location String in file-line-column format

Source

pub fn get_datestamp(&self) -> &Option<NaiveDate>

Returns the error’s NaiveDate datestamp as a String

Source

pub fn get_timestamp(&self) -> &Option<NaiveTime>

Returns the error’s NaiveTime timestamp as a String

Source

pub fn get_datetime(&self) -> Option<(String, String)>

Returns the error’s datetime stamp as a String

Source

pub fn with_type(self, error_type: SystemErrorCodes) -> Self

Description: Adds the error type to the error

Source

pub fn with_content(self, error_content: String) -> Self

Description: Adds the error content to the error

Source

pub fn with_file_data(self, file: String) -> Self

Description: Adds the file data to the error

Source

pub fn with_location_data(self, location: (u32, u32)) -> Self

Description: Adds the location data to the error

Source

pub fn with_datestamp_data(self, datestamp: NaiveDate) -> Self

Description: Adds the datestamp data to the error

Source

pub fn with_timestamp_data(self, timestamp: NaiveTime) -> Self

Description: Adds the timestamp data to the error

Source

pub fn add_error_type(&mut self, error_type: SystemErrorCodes)

Description: Allows the user to add the error type after creation

Source

pub fn add_error_content(&mut self, content: String)

Description: Allows the user to add the error content after creation

Source

pub fn add_file_data(&mut self, file: String)

Description: Allows the user to add the file data after creation

Source

pub fn add_location_data(&mut self, location: (u32, u32))

Description: Allows the user to add the location data after creation

Source

pub fn add_datestamp_data(&mut self, datestamp: NaiveDate)

Description: Allows the user to add the datestamp data after creation

Source

pub fn add_timestamp_data(&mut self, timestamp: NaiveTime)

Description: Allows the user to add the timestamp data after creation

Trait Implementations§

Source§

impl Debug for TheError

Source§

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

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

impl Default for TheError

Source§

fn default() -> TheError

Returns the “default value” for a type. Read more
Source§

impl Display for TheError

Source§

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

Formatter function to display the error in a simple manner.

No overhead, just the error type and content. If the user needs more information and was previously stored, it’ll be inside TheError struct.

Source§

impl From<TheError> for TheErrorType

Source§

fn from(value: TheError) -> Self

Converts to this type from the input type.

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.