pub enum Error {
InvalidArgument(&'static str),
Type(&'static str),
}Expand description
Why a DSN was refused or a parameter could not be read.
Variants§
InvalidArgument(&'static str)
The DSN is malformed or lacks a scheme or host.
PHP: \InvalidArgumentException.
use utopia_dsn::{Dsn, Error};
let error = Dsn::parse("localhost:3306").unwrap_err();
assert!(matches!(error, Error::InvalidArgument(_)));
assert_eq!(error.to_string(), "Unable to parse DSN: scheme is required");use Utopia\DSN\DSN;
try {
new DSN('localhost:3306');
} catch (\InvalidArgumentException $e) {
echo $e->getMessage(), "\n"; // Unable to parse DSN: scheme is required
}Type(&'static str)
Dsn::param was called on a key the query holds as a list or map
(a[b]=c), which has no single value to return.
PHP: \TypeError, as PHP cannot return an array as a string.
Implementations§
Source§impl Error
impl Error
Sourcepub fn php_class(&self) -> &'static str
pub fn php_class(&self) -> &'static str
The name of the exception class this error matches, such as
InvalidArgumentException.
PHP: the class of the exception utopia-php/dsn throws for the same
input.
use utopia_dsn::Dsn;
let error = Dsn::parse("redis://").unwrap_err();
assert_eq!(error.php_class(), "InvalidArgumentException");use Utopia\DSN\DSN;
try {
new DSN('redis://');
} catch (\Throwable $e) {
echo get_class($e), "\n"; // InvalidArgumentException
}Trait Implementations§
impl Eq for Error
Source§impl Error for Error
impl Error for Error
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()
impl StructuralPartialEq for Error
Auto Trait Implementations§
impl Forget for Error
impl Freeze for Error
impl Move for Error
impl RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin for Error
impl UnwindSafe for Error
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.