Struct taos_error::Error
source · pub struct Error { /* private fields */ }Implementations§
source§impl Error
impl Error
sourcepub fn new(code: impl Into<Code>, err: impl Into<Cow<'static, str>>) -> Self
pub fn new(code: impl Into<Code>, err: impl Into<Cow<'static, str>>) -> Self
Examples found in repository?
src/lib.rs (line 123)
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
fn from(dsn: DsnError) -> Self {
Self::new(Code::Failed, dsn.to_string())
}
}
pub type Result<T> = std::result::Result<T, Error>;
impl Error {
#[inline]
pub fn new(code: impl Into<Code>, err: impl Into<Cow<'static, str>>) -> Self {
Self {
code: code.into(),
err: err.into(),
#[cfg(nightly)]
#[cfg_attr(nightly, no_coverage)]
backtrace: Backtrace::capture(),
}
}
#[inline]
pub fn errno(&self) -> Code {
self.code
}
#[inline]
pub const fn code(&self) -> Code {
self.code
}
#[inline]
pub fn message(&self) -> &str {
&self.err
}
#[inline]
pub fn from_code(code: impl Into<Code>) -> Self {
Self::new(code, "")
}
#[inline]
pub fn from_string(err: impl Into<Cow<'static, str>>) -> Self {
Self::new(Code::Failed, err)
}
#[inline]
pub fn from_any(err: impl Display) -> Self {
Self::new(Code::Failed, err.to_string())
}pub fn errno(&self) -> Code
pub const fn code(&self) -> Code
pub fn message(&self) -> &str
pub fn from_code(code: impl Into<Code>) -> Self
sourcepub fn from_string(err: impl Into<Cow<'static, str>>) -> Self
pub fn from_string(err: impl Into<Cow<'static, str>>) -> Self
Examples found in repository?
src/lib.rs (line 176)
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
Ok(Self::from_string(s.to_string()))
}
}
impl Display for Error {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if self.code == Code::Failed {
write!(f, "{}", self.err)
} else {
write!(f, "[{:#06X}] {}", self.code, self.err)
}
}
}
#[cfg(feature = "serde")]
impl serde::de::Error for Error {
#[inline]
fn custom<T: fmt::Display>(msg: T) -> Error {
Error::from_string(format!("{}", msg))
}pub fn from_any(err: impl Display) -> Self
Trait Implementations§
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)>
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()
source§impl Error for Error
impl Error for Error
source§fn custom<T: Display>(msg: T) -> Error
fn custom<T: Display>(msg: T) -> Error
Raised when there is general error when deserializing a type. Read more
source§fn invalid_type(unexp: Unexpected<'_>, exp: &dyn Expected) -> Self
fn invalid_type(unexp: Unexpected<'_>, exp: &dyn Expected) -> Self
Raised when a
Deserialize receives a type different from what it was
expecting. Read moresource§fn invalid_value(unexp: Unexpected<'_>, exp: &dyn Expected) -> Self
fn invalid_value(unexp: Unexpected<'_>, exp: &dyn Expected) -> Self
Raised when a
Deserialize receives a value of the right type but that
is wrong for some other reason. Read moresource§fn invalid_length(len: usize, exp: &dyn Expected) -> Self
fn invalid_length(len: usize, exp: &dyn Expected) -> Self
Raised when deserializing a sequence or map and the input data contains
too many or too few elements. Read more
source§fn unknown_variant(variant: &str, expected: &'static [&'static str]) -> Self
fn unknown_variant(variant: &str, expected: &'static [&'static str]) -> Self
Raised when a
Deserialize enum type received a variant with an
unrecognized name.source§fn unknown_field(field: &str, expected: &'static [&'static str]) -> Self
fn unknown_field(field: &str, expected: &'static [&'static str]) -> Self
Raised when a
Deserialize struct type received a field with an
unrecognized name.source§fn missing_field(field: &'static str) -> Self
fn missing_field(field: &'static str) -> Self
Raised when a
Deserialize struct type expected to receive a required
field with a particular name but that field was not present in the
input.source§fn duplicate_field(field: &'static str) -> Self
fn duplicate_field(field: &'static str) -> Self
Raised when a
Deserialize struct type received more than one of the
same field.