pub struct SQError { /* private fields */ }
Expand description
A SQError contains a TS3 Server Query error.
Example
use sqlib::error::SQError;
let line = "error id=0 msg=ok".to_string();
let err_option = SQError::parse(&line);
let err = match err_option {
Some(err) => err,
None => { panic!("no error found"); },
};
assert_eq!(0, err.id());
Implementations
sourceimpl SQError
impl SQError
pub fn new(id: u32, msg: String) -> SQError
sourcepub fn parse_is_ok(s: &str) -> Result<bool>
pub fn parse_is_ok(s: &str) -> Result<bool>
This function tries to parse a string into an Error.
Return values
- If it fails to parse it returns Ok(false).
- If it parses the string as an OK error it returns Ok(true).
- If it parses the string as another error it returns Err(error).
Example
use sqlib::error::{Error, SQError};
let ok_str = "error id=0 msg=ok";
let no_err_str = "this is no error";
let err_str = "error id=1 msg=test";
let test_err = SQError::new(1, "test".to_string());
let to_test_error = match SQError::parse_is_ok(err_str).unwrap_err() {
Error::SQ(e) => e,
_ => SQError::ok(),
};
assert_eq!(SQError::parse_is_ok(ok_str).unwrap(), true);
assert_eq!(SQError::parse_is_ok(no_err_str).unwrap(), false);
assert_eq!(to_test_error, test_err);
pub fn id(&self) -> u32
pub fn msg(&self) -> String
Trait Implementations
sourceimpl Error for SQError
impl Error for SQError
sourcefn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
1.30.0 · sourcefn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
The lower-level source of this error, if any. Read more
impl Eq for SQError
Auto Trait Implementations
impl RefUnwindSafe for SQError
impl Send for SQError
impl Sync for SQError
impl Unpin for SQError
impl UnwindSafe for SQError
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more