Skip to content

Commit fb3ff2d

Browse files
committed
Merge #139: Improve errors
c89065d Make struct error internals public (Tobin C. Harding) ac24f23 Remove unused error types (Tobin C. Harding) Pull request description: Audit all error types as per discussion in rust-bitcoin/rust-bitcoin#820 I believe with these patches applied we are good to go for v1.0 in regards to error handling. ACKs for top commit: apoelstra: ACK c89065d Tree-SHA512: 1f0f49c5c6b42c51001544b213f0a9109e92a64458959e328fb0c7f8d01b47bfa56da47cba6bcb73096418a4873cb643cbc8c6e124923db0f5389985baaac511
2 parents 202b59f + c89065d commit fb3ff2d

File tree

3 files changed

+1
-95
lines changed

3 files changed

+1
-95
lines changed

src/lib.rs

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -384,53 +384,6 @@ impl From<UncheckedHrpstringError> for DecodeError {
384384
fn from(e: UncheckedHrpstringError) -> Self { Self::Parse(e) }
385385
}
386386

387-
/// An error while decoding an address from a reader.
388-
#[cfg(feature = "std")]
389-
#[derive(Debug)]
390-
#[non_exhaustive]
391-
pub enum DecodeFromReaderError {
392-
/// Read error.
393-
Read(std::io::Error),
394-
/// Decode error.
395-
Decode(DecodeError),
396-
}
397-
398-
#[cfg(feature = "std")]
399-
impl fmt::Display for DecodeFromReaderError {
400-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
401-
use DecodeFromReaderError::*;
402-
403-
match *self {
404-
Read(ref e) => write_err!(f, "read failed"; e),
405-
Decode(ref e) => write_err!(f, "decoding failed"; e),
406-
}
407-
}
408-
}
409-
410-
#[cfg(feature = "std")]
411-
impl std::error::Error for DecodeFromReaderError {
412-
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
413-
use DecodeFromReaderError::*;
414-
415-
match *self {
416-
Read(ref e) => Some(e),
417-
Decode(ref e) => Some(e),
418-
}
419-
}
420-
}
421-
422-
#[cfg(feature = "std")]
423-
impl From<std::io::Error> for DecodeFromReaderError {
424-
#[inline]
425-
fn from(e: std::io::Error) -> Self { Self::Read(e) }
426-
}
427-
428-
#[cfg(feature = "std")]
429-
impl From<DecodeError> for DecodeFromReaderError {
430-
#[inline]
431-
fn from(e: DecodeError) -> Self { Self::Decode(e) }
432-
}
433-
434387
#[cfg(test)]
435388
#[cfg(feature = "alloc")]
436389
mod tests {

src/primitives/segwit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pub fn validate_witness_program_length(
5555
/// Field element does not represent a valid witness version.
5656
#[derive(Debug, Clone, PartialEq, Eq)]
5757
#[non_exhaustive]
58-
pub struct InvalidWitnessVersionError(Fe32);
58+
pub struct InvalidWitnessVersionError(pub Fe32);
5959

6060
impl fmt::Display for InvalidWitnessVersionError {
6161
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {

src/segwit.rs

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -288,53 +288,6 @@ impl From<SegwitHrpstringError> for DecodeError {
288288
fn from(e: SegwitHrpstringError) -> Self { Self(e) }
289289
}
290290

291-
/// An error while decoding a segwit address from a reader.
292-
#[cfg(feature = "std")]
293-
#[derive(Debug)]
294-
#[non_exhaustive]
295-
pub enum DecodeFromReaderError {
296-
/// Read error.
297-
Read(std::io::Error),
298-
/// Decode error.
299-
Decode(DecodeError),
300-
}
301-
302-
#[cfg(feature = "std")]
303-
impl fmt::Display for DecodeFromReaderError {
304-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
305-
use DecodeFromReaderError::*;
306-
307-
match *self {
308-
Read(ref e) => write_err!(f, "read failed"; e),
309-
Decode(ref e) => write_err!(f, "decoding failed"; e),
310-
}
311-
}
312-
}
313-
314-
#[cfg(feature = "std")]
315-
impl std::error::Error for DecodeFromReaderError {
316-
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
317-
use DecodeFromReaderError::*;
318-
319-
match *self {
320-
Read(ref e) => Some(e),
321-
Decode(ref e) => Some(e),
322-
}
323-
}
324-
}
325-
326-
#[cfg(feature = "std")]
327-
impl From<std::io::Error> for DecodeFromReaderError {
328-
#[inline]
329-
fn from(e: std::io::Error) -> Self { Self::Read(e) }
330-
}
331-
332-
#[cfg(feature = "std")]
333-
impl From<DecodeError> for DecodeFromReaderError {
334-
#[inline]
335-
fn from(e: DecodeError) -> Self { Self::Decode(e) }
336-
}
337-
338291
/// An error while constructing a [`SegwitHrpstring`] type.
339292
#[derive(Debug, Clone, PartialEq, Eq)]
340293
#[non_exhaustive]

0 commit comments

Comments
 (0)