Wrap ErrorKind in Io enum variant, fix doc comment for the IO variant
This commit is contained in:
parent
1a2b54ff23
commit
6e06a32ccc
|
@ -128,8 +128,9 @@ pub enum SigHashType {
|
||||||
/// Possible errors in computing the signature message
|
/// Possible errors in computing the signature message
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// Should never happen since we are always encoding, thus we are avoiding wrap the IO error
|
/// Could happen only by using `*_encode_signing_*` methods with custom writers, engines writers
|
||||||
IoError,
|
/// like the ones used in methods `*_signature_hash` don't error
|
||||||
|
Io(io::ErrorKind),
|
||||||
|
|
||||||
/// Requested index is greater or equal than the number of inputs in the transaction
|
/// Requested index is greater or equal than the number of inputs in the transaction
|
||||||
IndexOutOfInputsBounds {
|
IndexOutOfInputsBounds {
|
||||||
|
@ -166,7 +167,7 @@ pub enum Error {
|
||||||
impl fmt::Display for Error {
|
impl fmt::Display for Error {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
Error::IoError => write!(f, "IoError"),
|
Error::Io(ref e) => write!(f, "Writer errored: {:?}", e),
|
||||||
Error::IndexOutOfInputsBounds { index, inputs_size } => write!(f, "Requested index ({}) is greater or equal than the number of transaction inputs ({})", index, inputs_size),
|
Error::IndexOutOfInputsBounds { index, inputs_size } => write!(f, "Requested index ({}) is greater or equal than the number of transaction inputs ({})", index, inputs_size),
|
||||||
Error::SingleWithoutCorrespondingOutput { index, outputs_size } => write!(f, "SIGHASH_SINGLE for input ({}) haven't a corresponding output (#outputs:{})", index, outputs_size),
|
Error::SingleWithoutCorrespondingOutput { index, outputs_size } => write!(f, "SIGHASH_SINGLE for input ({}) haven't a corresponding output (#outputs:{})", index, outputs_size),
|
||||||
Error::PrevoutsSize => write!(f, "Number of supplied prevouts differs from the number of inputs in transaction"),
|
Error::PrevoutsSize => write!(f, "Number of supplied prevouts differs from the number of inputs in transaction"),
|
||||||
|
@ -640,8 +641,8 @@ impl<R: DerefMut<Target = Transaction>> SigHashCache<R> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<io::Error> for Error {
|
impl From<io::Error> for Error {
|
||||||
fn from(_: io::Error) -> Self {
|
fn from(e: io::Error) -> Self {
|
||||||
Error::IoError
|
Error::Io(e.kind())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue