Subject: | detect fault and not error |
The spec dictates that the structure for an error be contained in a
fault node. Jabber::RPC::Client is expecting an error node and a code
attribute.
Spec: http://www.jabber.org/jeps/jep-0009.html
I have attached a patch file to handle the fault node structure.
Subject: | patch.txt |
--- Client.pm 2002-06-14 05:41:57.000000000 -0400
+++ Copy of Client.pm 2006-02-27 16:44:15.309559000 -0500
@@ -140,8 +140,22 @@
# Check for error
if ($result->attr('type') eq IQ_ERROR) {
- my $error = $result->getTag('error');
- $self->{lastfault} = $error->data." (".$error->attr('code').")";
+ my $error = $result->getTag('query', NS_RPC)->getTag('methodResponse')->getTag('fault');
+
+ my @error_data = $error->getTag('value')->getTag('struct')->getTag('member');
+
+ my($error_code_node, $error_str_node);
+
+ foreach my $err (@error_data) {
+ if($err->getTag('name')->data eq "faultCode") {
+ $error_code_node = $err->getTag('value');
+ } elsif($err->getTag('name')->data eq "faultString") {
+ $error_str_node = $err->getTag('value');
+ }
+ }
+
+ $self->{lastfault} = $error_str_node->getTag('string')->data . " (" . $error_code_node->getTag('int')->data . ")";
+
return;
}