NAME
Bitcoin::Crypto::Exception - Exception class for Bitcoin::Crypto purposes
SYNOPSIS
use Try::Tiny;
try {
decode_segwit("Not a segwit address");
} catch {
my $error = $_;
# $error is an instance of Bitcoin::Crypto::Exception and stringifies automatically
warn "$error";
# but also contains some information about the problem to avoid regex matching
if ($error->isa("Bitcoin::Crypto::Exception::Bech32InputFormat")) {
log $error->message;
}
};
DESCRIPTION
A wrapper class with automatic stringification and standarized raising using Throwable::Error. Contains many other inline packages that identify parts that went wrong (like Bitcoin::Crypto::Exception::KeySign for errors in signature generation). See individual Bitcoin::Crypto packages documentation to see the exception classes to check for extra control flow when needed.
FUNCTIONS
raise
Bitcoin::Crypto::Exception->raise("error message");
Creates a new instance and throws it. If used on an object, throws it right away.
throw
Same as raise.
trap_into
Bitcoin::Crypto::Exception->trap_into(sub {
die "something went wrong";
});
Executes the subroutine given as the only parameter inside an eval. Any exceptions thrown inside the subroutine will be re-thrown after turning them into objects of the given class.