report invalid databases
authorDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 22 Oct 2010 23:18:08 +0000 (01:18 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 22 Oct 2010 23:18:08 +0000 (01:18 +0200)
server.pl

index 8d7c60d..2f834dc 100755 (executable)
--- a/server.pl
+++ b/server.pl
@@ -41,8 +41,14 @@ diag "SearchHandle ",Dumper($this);
     my $rpn     = $this->{RPN};
     my $query;
 
-       my $database = $this->{DATABASES}->[0];
-       my $module   = $databases->{$database} || 'COBISS';
+       my $database = uc $this->{DATABASES}->[0];
+       my $module = $databases->{$database};
+       if ( ! defined $module ) {
+        $this->{ERR_CODE} = 108;
+               warn $this->{ERR_STR} = "unknown database $database - available: " . keys %$databases;
+               return;
+       }
+
        my $from = $module->new;
 
 diag "using $module for $database ", Dumper( $from );