util/error: refactor error handling
This commit is contained in:
@ -15,7 +15,7 @@ impl Audio {
|
||||
let mut got: c_int = 0;
|
||||
|
||||
match avcodec_encode_audio2(self.ptr, &mut out.val, frame.ptr, &mut got) {
|
||||
e if e < 0 => Err(Error::new(e)),
|
||||
e if e < 0 => Err(Error::from(e)),
|
||||
_ => Ok(got != 0)
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ impl Encoder {
|
||||
Ok(Video(self))
|
||||
}
|
||||
else {
|
||||
Err(Error::from(AVERROR_INVALIDDATA))
|
||||
Err(Error::InvalidData)
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,7 +47,7 @@ impl Encoder {
|
||||
Ok(Audio(self))
|
||||
}
|
||||
else {
|
||||
Err(Error::from(AVERROR_INVALIDDATA))
|
||||
Err(Error::InvalidData)
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ impl Encoder {
|
||||
Ok(Subtitle(self))
|
||||
}
|
||||
else {
|
||||
Err(Error::from(AVERROR_INVALIDDATA))
|
||||
Err(Error::InvalidData)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ impl Subtitle {
|
||||
pub fn encode(&self, subtitle: &::Subtitle, out: &mut [u8]) -> Result<bool, Error> {
|
||||
unsafe {
|
||||
match avcodec_encode_subtitle(self.ptr, out.as_mut_ptr(), out.len() as c_int, &subtitle.val) {
|
||||
e if e < 0 => Err(Error::new(e)),
|
||||
e if e < 0 => Err(Error::from(e)),
|
||||
_ => Ok(true)
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ impl Video {
|
||||
let mut got: c_int = 0;
|
||||
|
||||
match avcodec_encode_video2(self.ptr, &mut out.val, frame.ptr, &mut got) {
|
||||
e if e < 0 => Err(Error::new(e)),
|
||||
e if e < 0 => Err(Error::from(e)),
|
||||
_ => Ok(got != 0)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user