-# $Id: ZOOM.pm,v 1.16 2005-11-08 16:42:08 mike Exp $
+# $Id: ZOOM.pm,v 1.18 2005-11-16 14:49:30 mike Exp $
use strict;
use warnings;
return $this->{addinfo};
}
+sub render {
+ my $this = shift();
+ my $res = "ZOOM error " . $this->code() . ' "' . $this->message() . '"';
+ $res .= ' (addinfo: "' . $this->addinfo() . '")' if $this->addinfo();
+ return $res;
+}
+
+# This means that untrapped exceptions render nicely.
+use overload '""' => \&render;
# ----------------------------------------------------------------------------
my $class = shift();
my($host, $port) = @_;
- my $_conn = Net::Z3950::ZOOM::connection_new($host, $port);
+ my $_conn = Net::Z3950::ZOOM::connection_new($host, $port || 0);
my($errcode, $errmsg, $addinfo) = (undef, "dummy", "dummy");
$errcode = Net::Z3950::ZOOM::connection_error($_conn, $errmsg, $addinfo);
die new ZOOM::Exception($errcode, $errmsg, $addinfo) if $errcode;
my $raw = Net::Z3950::ZOOM::resultset_records($this->_rs(), $start, $count,
$return_records);
+ ### Why don't we throw an exception if $raw is undefined?
return undef if !defined $raw;
# We need to package up the returned records in ZOOM::Record objects
return $_ss;
}
+sub option {
+ my $this = shift();
+ my($key, $value) = @_;
+
+ my $oldval = Net::Z3950::ZOOM::scanset_option_get($this->_ss(), $key);
+ Net::Z3950::ZOOM::scanset_option_set($this->_ss(), $key, $value)
+ if defined $value;
+
+ return $oldval;
+}
+
sub size {
my $this = shift();
my($occ, $len) = (0, 0);
my $term = Net::Z3950::ZOOM::scanset_term($this->_ss(), $which,
$occ, $len);
+ ### Throw exception?
return undef if !defined $term;
die "length of term '$term' differs from returned len=$len"
if length($term) != $len;
my($occ, $len) = (0, 0);
my $term = Net::Z3950::ZOOM::scanset_display_term($this->_ss(), $which,
$occ, $len);
+ ### Throw exception?
return undef if !defined $term;
die "length of display term '$term' differs from returned len=$len"
if length($term) != $len;