Skip to content

Commit

Permalink
Rework error wrapping
Browse files Browse the repository at this point in the history
  • Loading branch information
atoktoto committed Jan 8, 2024
1 parent 1ae8cff commit e06fd58
Show file tree
Hide file tree
Showing 25 changed files with 119 additions and 286 deletions.
5 changes: 3 additions & 2 deletions symphonia-bundle-mp3/src/layer3/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
use std::fmt;

use symphonia_core::audio::{AudioBuffer, Signal};
use symphonia_core::errors::{decode_error, Error, IoErrorKind, Result};
use symphonia_core::errors::{decode_error, Result};
use symphonia_core::errors::SymphoniaError as Error;
use symphonia_core::io::{BitReaderLtr, BufReader, ReadBitsLtr, ReadBytes};

mod bitstream;
Expand Down Expand Up @@ -356,7 +357,7 @@ impl Layer3 {
// IO error to a decode error.
frame_data.granules[gr].channels[ch].rzero = match huffman_result {
Ok(rzero) => rzero,
Err(Error::IoError(IoErrorKind::Other, _)) => {
Err(Error::IoError(_)) => {
return decode_error("mpa: huffman decode overrun");
}
Err(err) => return Err(err),
Expand Down
2 changes: 2 additions & 0 deletions symphonia-bundle-mp3/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#![allow(clippy::identity_op)]
#![allow(clippy::manual_range_contains)]

extern crate alloc;

// Shared modules.
mod common;
mod header;
Expand Down
5 changes: 3 additions & 2 deletions symphonia-check/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ use std::process::{Command, Stdio};

use symphonia::core::audio::{AudioBufferRef, SampleBuffer};
use symphonia::core::codecs::{Decoder, DecoderOptions};
use symphonia::core::errors::{Error, IoErrorKind, Result};
use symphonia::core::errors::Result;
use symphonia::core::errors::SymphoniaError as Error;
use symphonia::core::formats::{FormatOptions, FormatReader};
use symphonia::core::io::{MediaSourceStream, ReadOnlySource};
use symphonia::core::meta::MetadataOptions;
Expand Down Expand Up @@ -396,7 +397,7 @@ fn main() {
println!();

match run_test(path, &opts, &mut res) {
Err(Error::IoError(IoErrorKind::UnexpectedEof, _)) => (),
Err(Error::EndOfFile) => (),
Err(err) => {
eprintln!("Test interrupted by error: {}", err);
std::process::exit(2);
Expand Down
2 changes: 2 additions & 0 deletions symphonia-codec-aac/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
// TODO: Remove this when refactoring AAC.
#![allow(clippy::needless_range_loop)]

extern crate alloc;

mod aac;
mod adts;
mod common;
Expand Down
2 changes: 2 additions & 0 deletions symphonia-codec-adpcm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ use symphonia_core::errors::{unsupported_error, Result};
use symphonia_core::formats::Packet;
use symphonia_core::io::ReadBytes;

extern crate alloc;

mod codec_ima;
mod codec_ms;
mod common;
Expand Down
2 changes: 2 additions & 0 deletions symphonia-codec-alac/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ use symphonia_core::formats::Packet;
use symphonia_core::io::{BitReaderLtr, BufReader, FiniteStream, ReadBitsLtr, ReadBytes};
use symphonia_core::support_codec;

extern crate alloc;

/// Supported ALAC version.
const ALAC_VERSION: u8 = 0;

Expand Down
7 changes: 4 additions & 3 deletions symphonia-codec-vorbis/src/floor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
use std::cmp::min;
use std::collections::HashSet;

use symphonia_core::errors::{decode_error, Error, IoErrorKind, Result};
use symphonia_core::errors::SymphoniaError as Error;
use symphonia_core::errors::{decode_error, Result};
use symphonia_core::io::{BitReaderRtl, ReadBitsRtl};

use super::codebook::VorbisCodebook;
Expand Down Expand Up @@ -92,7 +93,7 @@ macro_rules! io_try_or_ret {
// An end-of-bitstream error is classified under ErrorKind::Other. This condition
// should not be treated as an error, rather, it should return from the function
// immediately without error.
Err(Error::IoError(IoErrorKind::Other, _)) => return Ok(()),
Err(Error::EndOfFile) => return Ok(()),
Err(e) => return Err(e.into()),
}
};
Expand All @@ -105,7 +106,7 @@ macro_rules! try_or_ret {
// An end-of-bitstream error is classified under ErrorKind::Other. This condition
// should not be treated as an error, rather, it should return from the function
// immediately without error.
Err(Error::IoError(IoErrorKind::Other, _)) => return Ok(()),
Err(Error::EndOfFile) => return Ok(()),
Err(e) => return Err(e),
}
};
Expand Down
2 changes: 2 additions & 0 deletions symphonia-codec-vorbis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
// Disable to better express the specification.
#![allow(clippy::collapsible_else_if)]

extern crate alloc;

use symphonia_core::audio::{AsAudioBufferRef, AudioBuffer, AudioBufferRef};
use symphonia_core::audio::{Signal, SignalSpec};
use symphonia_core::codecs::{CodecDescriptor, CodecParameters, CODEC_TYPE_VORBIS};
Expand Down
5 changes: 3 additions & 2 deletions symphonia-codec-vorbis/src/residue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
use std::cmp::min;
use std::convert::TryInto;

use symphonia_core::errors::{decode_error, Error, IoErrorKind, Result};
use symphonia_core::errors::SymphoniaError as Error;
use symphonia_core::errors::{decode_error, Result};
use symphonia_core::io::{BitReaderRtl, ReadBitsRtl};

use super::codebook::VorbisCodebook;
Expand Down Expand Up @@ -154,7 +155,7 @@ impl Residue {
Ok(_) => (),
// An end-of-bitstream error is classified under ErrorKind::Other. This condition
// should not be treated as an error.
Err(Error::IoError(IoErrorKind::Other, _)) => (),
Err(Error::EndOfFile) => (),
Err(e) => return Err(e),
};

Expand Down
Loading

0 comments on commit e06fd58

Please sign in to comment.