1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// SPDX-License-Identifier: CC0-1.0

use std::fmt;

pub enum Error {
    InvalidSequence,
    PublicKeyHash,
    Sha256d,
    Ripemd160,
    Multisig,
    Extensions,
    CouldNotSatisfy,
}

impl fmt::Debug for Error {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match self {
            Error::InvalidSequence => writeln!(f, "Sequence does not encode relative locktime"),
            Error::PublicKeyHash => writeln!(f, "Public key hashes are not suppored"),
            Error::Sha256d => writeln!(f, "Sha256d is not supported"),
            Error::Ripemd160 => writeln!(f, "Ripemd160 is not supported"),
            Error::Multisig => writeln!(f, "Multisig is not supported"),
            Error::Extensions => writeln!(f, "Extensions are not supported"),
            Error::CouldNotSatisfy => writeln!(f, "Could not satisfy the given policy"),
        }
    }
}

impl fmt::Display for Error {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        fmt::Debug::fmt(self, f)
    }
}

impl std::error::Error for Error {}