changeset 265:aaffc50e3318

try to handle db_error
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Tue, 25 Nov 2008 20:15:26 +0800
parents 3b3f1306255a
children 53827cc442b6
files Ikariam.pm scan.pl
diffstat 2 files changed, 16 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/Ikariam.pm	Mon Nov 24 17:44:43 2008 +0800
+++ b/Ikariam.pm	Tue Nov 25 20:15:26 2008 +0800
@@ -1,14 +1,29 @@
+
 BEGIN {
     foreach (((getpwuid($<))[7], $ENV{HOME}, $ENV{LOGDIR}, ".")) {
         require "$_/.eagleeye.pm" if (-f "$_/.eagleeye.pm");
     }
 }
 
+package Ikariam::Base;
+use strict;
+require Class::DBI::SQLite;
+use base qw(Class::DBI::SQLite);
+
+sub _db_error {
+    my ($self, %info) = @_;
+    my $msg = delete $info{msg};
+    die($msg);
+# return $self->_carp($msg, %info);
+}
+
+1;
+
 use Class::DBI::AutoLoader (
     dsn       => 'dbi:SQLite:dbname=ikariam.sqlite',
     options   => { RaiseError => 1 },
     tables    => ['cities', 'island', 'user', 'ally', 'report'],
-    use_base  => 'Class::DBI::SQLite',
+    use_base  => 'Ikariam::Base',
     namespace => 'Ikariam',
 );
 
--- a/scan.pl	Mon Nov 24 17:44:43 2008 +0800
+++ b/scan.pl	Tue Nov 25 20:15:26 2008 +0800
@@ -25,12 +25,6 @@
     return bless $self, $class;
 }
 
-sub _croak {
-    my ($self, $message, %info) = @_;
-    Error->throw(-text => $message, %info);
-    return;
-}
-
 sub saveCities
 {
     my ($self, $island, @cities) = @_;