BZ::Client::Exception - Exception class thrown by BZ::Client in case of errors.
version 4.4004
BZ::Client does not return error codes or do similar stuff. Instead, it throws instances of BZ::Client::Exception.
my $exception = BZ::Client::Exception->new( message => $message, http_code => $httpCode, xmlrpc_code => $xmlrpcCode ); BZ::Client::Exception->throw( message => $message, http_code => $httpCode, xmlrpc_code => $xmlrpcCode );
Creates the exception object
Creates the exception object then dies, so make sure you catch it!
Returns the error message text
Returns the error code from XMLRPC
Returns the http code (200, 404, etc)
Here are two examples. The first uses Perl's inbuilt eval() function, the second uses the Try::Tiny module. Further alternatives exist and may be perfectly good options if they suit you.
use BZ::Client; use BZ::Client::Bug::Attachment; use v5.10; my $client = BZ::Client->new( %etc ); eval { my $att = BZ::Client::Bug::Attachment->get($client, { ids => 30505 }); }; if ($@) { say 'An Error Occured'; say 'Message: ', $@->message(); say 'HTTP Code: ', $@->http_code() if $@->http_code(); say 'XMLrpc Code: ', $@->xmlrpc_code() if $@->xmlrpc_code(); };
use BZ::Client; use BZ::Client::Bug::Attachment; use Try::Tiny; use v5.10; my $client = BZ::Client->new( %etc ); try { my $att = BZ::Client::Bug::Attachment->get($client, { ids => 30505 }); } catch { say 'An Error Occured'; say 'Message: ', $_->message(); say 'HTTP Code: ', $_->http_code() if $_->http_code(); say 'XMLrpc Code: ', $_->xmlrpc_code() if $_->xmlrpc_code(); };
BZ::Client
Dean Hamstead <dean@bytefoundry.com.au>
Jochen Wiedmann <jochen.wiedmann@gmail.com>
This software is copyright (c) 2021 by Dean Hamstad.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install BZ::Client, copy and paste the appropriate command in to your terminal.
cpanm
cpanm BZ::Client
CPAN shell
perl -MCPAN -e shell install BZ::Client
For more information on module installation, please visit the detailed CPAN module installation guide.