rocket::config

Enum ConfigError

Source
pub enum ConfigError {
    NotFound,
    IoError,
    Io(Error, &'static str),
    BadFilePath(PathBuf, &'static str),
    BadEnv(String),
    BadEntry(String, PathBuf),
    BadType(String, &'static str, &'static str, Option<PathBuf>),
    ParseError(String, PathBuf, String, Option<(usize, usize)>),
    BadEnvVal(String, String, String),
    UnknownKey(String),
    Missing(String),
}
Expand description

The type of a configuration error.

Variants§

§

NotFound

The configuration file was not found.

§

IoError

There was an I/O error while reading the configuration file.

§

Io(Error, &'static str)

There was an I/O error while setting a configuration parameter.

Parameters: (io_error, config_param_name)

§

BadFilePath(PathBuf, &'static str)

The path at which the configuration file was found was invalid.

Parameters: (path, reason)

§

BadEnv(String)

An environment specified in ROCKET_ENV is invalid.

Parameters: (environment_name)

§

BadEntry(String, PathBuf)

An environment specified as a table [environment] is invalid.

Parameters: (environment_name, filename)

§

BadType(String, &'static str, &'static str, Option<PathBuf>)

A config key was specified with a value of the wrong type.

Parameters: (entry_name, expected_type, actual_type, filename)

§

ParseError(String, PathBuf, String, Option<(usize, usize)>)

There was a TOML parsing error.

Parameters: (toml_source_string, filename, error_description, line/col)

§

BadEnvVal(String, String, String)

There was a TOML parsing error in a config environment variable.

Parameters: (env_key, env_value, error)

§

UnknownKey(String)

The entry (key) is unknown.

Parameters: (key)

§

Missing(String)

The entry (key) was expected but was missing.

Parameters: (key)

Implementations§

Source§

impl ConfigError

Source

pub fn pretty_print(&self)

Prints this configuration error with Rocket formatting.

Source

pub fn is_not_found(&self) -> bool

Returns true if self is of NotFound variant.

§Example
use rocket::config::ConfigError;

let error = ConfigError::NotFound;
assert!(error.is_not_found());

Trait Implementations§

Source§

impl Debug for ConfigError

Source§

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

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

impl Display for ConfigError

Source§

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

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

impl Error for ConfigError

Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
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 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
Source§

impl PartialEq for ConfigError

Source§

fn eq(&self, other: &ConfigError) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

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, I> AsResult<T, I> for T
where I: Input,

Source§

fn as_result(self) -> Result<T, ParseErr<I>>

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.

§

impl<T> IntoCollection<T> for T

§

fn into_collection<A>(self) -> SmallVec<A>
where A: Array<Item = T>,

Converts self into a collection.
§

fn mapped<U, F, A>(self, f: F) -> SmallVec<A>
where F: FnMut(T) -> U, A: Array<Item = U>,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

default 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.
Source§

impl<T> Typeable for T
where T: Any,

Source§

fn get_type(&self) -> TypeId

Get the TypeId of this object.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V