stdio: nicer error handling
This commit is contained in:
parent
806ba1d0a8
commit
daf595fe56
1 changed files with 7 additions and 3 deletions
|
@ -7,6 +7,12 @@ pub struct Error {
|
||||||
pub errno: errno::Errno,
|
pub errno: errno::Errno,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<Error> for fmt::Error {
|
||||||
|
fn from(_err: Error) -> fmt::Error {
|
||||||
|
fmt::Error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub type Result<T> = core::result::Result<T, Error>;
|
pub type Result<T> = core::result::Result<T, Error>;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -58,9 +64,7 @@ impl BasicOStream {
|
||||||
impl fmt::Write for BasicOStream {
|
impl fmt::Write for BasicOStream {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn write_str(&mut self, s: &str) -> fmt::Result {
|
fn write_str(&mut self, s: &str) -> fmt::Result {
|
||||||
if self.write(s.as_bytes()).is_err() {
|
self.write(s.as_bytes())?;
|
||||||
return Err(fmt::Error);
|
|
||||||
}
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue