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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
|
package AnyEvent::XMPP::Error::Stream;
use AnyEvent::XMPP::Error;
use strict;
our @ISA = qw/AnyEvent::XMPP::Error/;
=head1 NAME
AnyEvent::XMPP::Error::Stream - XML Stream errors
Subclass of L<AnyEvent::XMPP::Error>
=cut
sub init {
my ($self) = @_;
my $node = $self->xml_node;
my @txt = $node->find_all ([qw/streams text/]);
my $error;
for my $er (
qw/bad-format bad-namespace-prefix conflict connection-timeout host-gone
host-unknown improper-addressing internal-server-error invalid-from
invalid-id invalid-namespace invalid-xml not-authorized policy-violation
remote-connection-failed resource-constraint restricted-xml
see-other-host system-shutdown undefined-condition unsupported-stanza-type
unsupported-version xml-not-well-formed/)
{
if (my (@n) = $node->find_all ([streams => $er])) {
$error = $n[0]->name;
last;
}
}
unless ($error) {
#d# warn "got undefined error stanza, trying to find any undefined error...";
for my $n ($node->nodes) {
if ($n->eq_ns ('streams')) {
$error = $n->name;
}
}
}
$self->{error_name} = $error;
$self->{error_text} = @txt ? $txt[0]->text : '';
}
=head2 METHODS
=over 4
=item B<xml_node ()>
Returns the L<AnyEvent::XMPP::Node> object for this stream error.
=cut
sub xml_node {
$_[0]->{node}
}
=item B<name ()>
Returns the name of the error. That might be undef, one of the following
strings or some other string that has been discovered by a heuristic
(because some servers send errors that are not in the RFC).
bad-format
bad-namespace-prefix
conflict
connection-timeout
host-gone
host-unknown
improper-addressing
internal-server-error
invalid-from
invalid-id
invalid-namespace
invalid-xml
not-authorized
policy-violation
remote-connection-failed
resource-constraint
restricted-xml
see-other-host
system-shutdown
undefined-condition
unsupported-stanza-type
unsupported-version
xml-not-well-formed
=cut
sub name { $_[0]->{error_name} }
=item B<text ()>
The humand readable error portion. Might be undef if none was received.
=cut
sub text { $_[0]->{error_text} }
sub string {
my ($self) = @_;
sprintf ("stream error: %s: %s",
$self->name,
$self->text)
}
=back
=cut
=head1 AUTHOR
Robin Redeker, C<< <elmex at ta-sa.org> >>, JID: C<< <elmex at jabber.org> >>
=head1 COPYRIGHT & LICENSE
Copyright 2007, 2008 Robin Redeker, all rights reserved.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
=cut
1; # End of AnyEvent::XMPP
|