|
NAMEKafka::Exceptions - Perl Kafka API exception definitions. VERSIONThis documentation refers to "Kafka::Exceptions" version 0.8010 . SYNOPSIS use 5.010;
use strict;
use warnings;
use Scalar::Util qw(
blessed
);
use Try::Tiny;
# A simple example of Kafka::Connection usage:
use Kafka::Connection;
# connect to local cluster with the defaults
my $connection;
try {
$connection = Kafka::Connection->new( host => 'localhost' );
} catch {
if ( blessed( $_ ) && $_->isa( 'Kafka::Exception' ) ) {
if ( $_->isa( 'Kafka::Exception::Connection' ) ) {
# Specific treatment for 'Kafka::Connection' class error
} elsif ( $_->isa( 'Kafka::Exception::IO' ) ) {
# Specific treatment for 'Kafka::IO' class error
}
warn ref( $_ ), " error:\n", $_->message, "\n", $_->trace->as_string, "\n";
exit;
} else {
die $_;
}
};
# Closes the connection and cleans up
undef $connection;
DESCRIPTIONThe purpose of the "Kafka::Exceptions" module is:
It is designed to make exception handling structured, simpler and better by encouraging use of hierarchy of exceptions in application (vs single catch-all exception class). The following additional attributes are available in "Kafka::Exception" and its subclasses:
Exception objects provide accessor methods for these attributes. Attributes are inherited by subclasses. Various Kafka API modules throw exceptions objects of a "Kafka::Exception" subclass specific to that module:
Authors suggest using of Try::Tiny's "try" and "catch" to handle exceptions while working with Kafka package. You may also want to review documentation of Exception::Class, which is the default base class for all exception objects created by this module. FUNCTIONSThe following functions are exported by "Kafka::Exceptions" module: "throw_args( $error_code, $description )" Converts arguments into "Kafka::Exception" constructor attributes "code" and "message". throw_args() accepts the following arguments:
SEE ALSOThe basic operation of the Kafka package modules: Kafka - constants and messages used by the Kafka package modules. Kafka::Connection - interface to connect to a Kafka cluster. Kafka::Producer - interface for producing client. Kafka::Consumer - interface for consuming client. Kafka::Message - interface to access Kafka message properties. Kafka::Int64 - functions to work with 64 bit elements of the protocol on 32 bit systems. Kafka::Protocol - functions to process messages in the Apache Kafka's Protocol. Kafka::IO - low-level interface for communication with Kafka server. Kafka::Exceptions - module designated to handle Kafka exceptions. Kafka::Internals - internal constants and functions used by several package modules. A wealth of detail about the Apache Kafka and the Kafka Protocol: Main page at <http://kafka.apache.org/> Kafka Protocol at <https://cwiki.apache.org/confluence/display/KAFKA/A+Guide+To+The+Kafka+Protocol> SOURCE CODEKafka package is hosted on GitHub: <https://github.com/TrackingSoft/Kafka> AUTHORSergey Gladkov, <sgladkov@trackingsoft.com> CONTRIBUTORSAlexander Solovey Jeremy Jordan Sergiy Zuban Vlad Marchenko COPYRIGHT AND LICENSECopyright (C) 2012-2013 by TrackingSoft LLC. This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic at <http://dev.perl.org/licenses/artistic.html>. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|