correct error detection code in export

This commit is contained in:
Graham Knop 2009-10-02 14:21:29 -05:00
parent 247166baf2
commit 62cb3a4b9c

View file

@ -791,14 +791,15 @@ sub exportWriteFile {
my $dest = $self->exportGetUrlAsPath;
my $parent = $dest->parent;
eval { $parent->absolute->mkpath };
if($@) {
WebGUI::Error->throw(error => "could not make directory " . $parent->absolute->stringify);
$parent->absolute->mkpath( {error => \my $err} );
if (@$err) {
(undef, my $message) = %{ $err->[0] };
WebGUI::Error->throw(error => "Could not make directory " . $parent->absolute->stringify . ": " . $message);
}
# next, get the contents, open the file, and write the contents to the file.
my $fh = eval { $dest->open('>:utf8') };
if($@) {
if(! $fh) {
WebGUI::Error->throw(error => "can't open " . $dest->absolute->stringify . " for writing: $!");
}
$self->session->asset($self);