-# $Id: ZOOM.pm,v 1.46 2007-02-26 14:36:55 mike Exp $
-
use strict;
use warnings;
use IO::File;
return Net::Z3950::ZOOM::diag_str($code);
}
+sub diag_srw_str {
+ my($code) = @_;
+
+ return Net::Z3950::ZOOM::diag_srw_str($code);
+}
+
sub event_str {
return Net::Z3950::ZOOM::event_str(@_);
}
$diagset ||= "ZOOM";
if (uc($diagset) eq "ZOOM" || uc($diagset) eq "BIB-1") {
$message ||= ZOOM::diag_str($code);
+ } elsif (lc($diagset) eq "info:srw/diagnostic/1") {
+ $message ||= ZOOM::diag_srw_str($code);
} else {
- # Should fill in messages for other diagsets, too.
+ # Should fill in messages for any other known diagsets.
+ $message ||= "(unknown error)";
}
return bless {
sub render {
my $this = shift();
- my $res = "ZOOM error " . $this->code() . ' "' . $this->message() . '"';
+
+ my $res = "ZOOM error " . $this->code();
+ $res .= ' "' . $this->message() . '"' if $this->message();
$res .= ' (addinfo: "' . $this->addinfo() . '")' if $this->addinfo();
$res .= " from diag-set '" . $this->diagset() . "'" if $this->diagset();
return $res;
return wantarray() ? ($errcode, $errmsg, $addinfo, $diagset) : $errcode;
}
+sub exception {
+ my $this = shift();
+
+ my($errcode, $errmsg, $addinfo, $diagset) = $this->error_x();
+ return undef if $errcode == 0;
+ return new ZOOM::Exception($errcode, $errmsg, $addinfo, $diagset);
+}
+
sub errcode {
my $this = shift();
return Net::Z3950::ZOOM::connection_errcode($this->_conn());
or ZOOM::_oops(ZOOM::Error::SORTBY, $sortby);
}
+sub sortby2 {
+ my $this = shift();
+ my($strategy, $sortby) = @_;
+
+ Net::Z3950::ZOOM::query_sortby2($this->_query(), $strategy, $sortby) == 0
+ or ZOOM::_oops(ZOOM::Error::SORTBY, $sortby);
+}
+
sub destroy {
my $this = shift();
my($type, $args) = @_;
$type = "$type;$args" if defined $args;
- my $len = 0;
- my $string = Net::Z3950::ZOOM::record_get($this->_rec(), $type, $len);
- # I don't think we need '$len' at all. ### Probably the Perl-to-C
- # glue code should use the value of `len' as well as the opaque
- # data-pointer returned, to ensure that the SV contains all of the
- # returned data and does not stop at the first NUL character in
- # binary data. Carefully check the ZOOM_record_get() documentation.
- return $string;
+ return Net::Z3950::ZOOM::record_get($this->_rec(), $type);
}
sub clone {
Net::Z3950::ZOOM::yaz_log($level, join("", @message));
}
+BEGIN { ZOOM::Log::mask_str("zoom_check"); }
1;