package DBIx::DBSchema;
use strict;
-use vars qw(@ISA $VERSION $DEBUG);
+use vars qw(@ISA $VERSION $DEBUG $errstr);
#use Exporter;
use Storable;
use DBIx::DBSchema::_util qw(_load_driver _dbh);
#@ISA = qw(Exporter);
@ISA = ();
-$VERSION = "0.31";
+$VERSION = "0.32";
$DEBUG = 0;
=head1 NAME
$schema = new_native DBIx::DBSchema $dsn, $user, $pass;
$schema->save("filename");
- $schema = load DBIx::DBSchema "filename";
+ $schema = load DBIx::DBSchema "filename" or die $DBIx::DBSchema::errstr;
$schema->addtable($dbix_dbschema_table_object);
=item load FILENAME
-Loads a DBIx::DBSchema object from a file.
+Loads a DBIx::DBSchema object from a file. If there is an error, returns
+false and puts an error message in $DBIx::DBSchema::errstr;
=cut
eval { $self = Storable::retrieve($file); };
if ( $@ && $@ =~ /not.*storable/i ) { #then try FreezeThaw
+ my $olderror = $@;
+
eval "use FreezeThaw;";
- die $@ if $@;
- open(FILE,"<$file") or die "Can't open $file: $!";
- my $string = join('',<FILE>);
- close FILE or die "Can't close $file: $!";
- ($self) = FreezeThaw::thaw($string);
+ if ( $@ ) {
+ $@ = $olderror;
+ } else {
+ open(FILE,"<$file")
+ or do { $errstr = "Can't open $file: $!"; return ''; };
+ my $string = join('',<FILE>);
+ close FILE
+ or do { $errstr = "Can't close $file: $!"; return ''; };
+ ($self) = FreezeThaw::thaw($string);
+ }
+ }
+
+ unless ( $self ) {
+ $errstr = $@;
}
$self;