Bitcoin::Crypto::Exception - Exception class for Bitcoin::Crypto purposes
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; } };
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.
Bitcoin::Crypto::Exception->raise("error message");
Creates a new instance and throws it. If used on an object, throws it right away.
Same as raise.
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.
To install Bitcoin::Crypto, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Bitcoin::Crypto
CPAN shell
perl -MCPAN -e shell install Bitcoin::Crypto
For more information on module installation, please visit the detailed CPAN module installation guide.