Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Exceptions instead of carp

  • Loading branch information...
commit a660875e9398a86224fb7535e8515246c604e44b 1 parent b7e816c
matias alejo garcia authored
View
8 lib/SQL/Bibliosoph.pm
@@ -263,7 +263,9 @@ package SQL::Bibliosoph; {
$self->d('Q ch_',$name,@_);
- croak "we calling a ch_* function, first argument must be a hash_ref and must have a 'ttl' keyword" if ref ($cfg) ne 'HASH' || ! ( $ttl = $cfg->{ttl} );
+ SQL::Bibliosoph::Exception::CallError->throw(
+ desc => "when calling a ch_* function, first argument must be a hash_ref and must have a 'ttl' keyword"
+ ) if ref ($cfg) ne 'HASH' || ! ( $ttl = $cfg->{ttl} );
if (! $self->memc() ) {
$self->d("\n\tMemcached is NOT used, no server is defined");
@@ -361,7 +363,9 @@ package SQL::Bibliosoph; {
$self->d('Q ch_',$name,@_);
- croak "we calling a ch_* function, first argument must be a hash_ref and must have a 'ttl' keyword" if ref ($cfg) ne 'HASH' || ! ( $ttl = $cfg->{ttl} );
+ SQL::Bibliosoph::Exception::CallError->throw(
+ desc => "when calling a ch_* function, first argument must be a hash_ref and must have a 'ttl' keyword"
+ ) if ref ($cfg) ne 'HASH' || ! ( $ttl = $cfg->{ttl} );
if (! $self->memc() ) {
$self->d("\n\tMemcached is NOT used, no server is defined");
View
10 lib/SQL/Bibliosoph/CatalogFile.pm
@@ -1,9 +1,9 @@
package SQL::Bibliosoph::CatalogFile; {
use Moose;
use utf8;
- use Carp;
use Data::Dumper;
use Package::Constants;
+ use SQL::Bibliosoph::Exceptions;
our $VERSION = "2.00";
@@ -25,7 +25,9 @@ package SQL::Bibliosoph::CatalogFile; {
$self->read_only(1);
}
- croak "File does not exists $file " if ! -e $file;
+ SQL::Bibliosoph::Exception::CatalogFileError->throw(
+ desc => "File does not exists $file "
+ ) if ! -e $file;
}
#------------------------------------------------------------------
@@ -116,7 +118,9 @@ package SQL::Bibliosoph::CatalogFile; {
my $FH;
open ($FH,$file)
- or croak "Could not read \"".$file."\" : $!";
+ or SQL::Bibliosoph::Exception::CatalogFileError->throw(
+ desc => "Could not read \"".$file."\" : $!"
+ ) if ! -e $file;
my @all = <$FH>;
close ($FH);
View
11 lib/SQL/Bibliosoph/Query.pm
@@ -1,6 +1,5 @@
package SQL::Bibliosoph::Query; {
use Moose;
- use Carp;
use DBI;
use Data::Dumper;
use Time::HiRes qw(gettimeofday tv_interval);
@@ -46,7 +45,9 @@ package SQL::Bibliosoph::Query; {
#say 'Preparing "' . $self->name() ;
$self->sth( $self->dbh()->prepare_cached($st) )
- or croak "error preparing : $st";
+ or SQL::Bibliosoph::Exception::QuerySyntaxError->throw(
+ desc => "error preparing : $st"
+ );
# Set numeric bind variables
foreach (@$numeric_fields) {
@@ -141,9 +142,9 @@ package SQL::Bibliosoph::Query; {
}
$self->bind_params($total);
- croak "Bad statament use ALL numbered bind variables, or NONE, but don't mix them in $$st "
- if $numbered && $numbered != $total;
-
+ SQL::Bibliosoph::Exception::QuerySyntaxError->throw(
+ desc => "Bad statament use ALL numbered bind variables, or NONE, but don't mix them in $$st"
+ ) if $numbered && $numbered != $total;
# Replaces nums
$$st =~ s/\#?\d*?\?/?/g;
Please sign in to comment.
Something went wrong with that request. Please try again.