From 28d7b0dba69de87e685c66e9dab135916e19ce88 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Fri, 9 Jan 2015 14:50:42 +0100 Subject: [PATCH] Write fatal errors to console as well --- lib/Slic3r/GUI.pm | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/Slic3r/GUI.pm b/lib/Slic3r/GUI.pm index ed90c5aa2..0c7122c42 100644 --- a/lib/Slic3r/GUI.pm +++ b/lib/Slic3r/GUI.pm @@ -82,9 +82,13 @@ sub OnInit { # just checking for existence of $datadir is not enough: it may be an empty directory # supplied as argument to --datadir; in that case we should still run the wizard my $run_wizard = (-d $enc_datadir && -e "$enc_datadir/slic3r.ini") ? 0 : 1; - for ($enc_datadir, "$enc_datadir/print", "$enc_datadir/filament", "$enc_datadir/printer") { - mkdir or $self->fatal_error("Slic3r was unable to create its data directory at $_ (errno: $!).") - unless -d $_; + foreach my $dir ($enc_datadir, "$enc_datadir/print", "$enc_datadir/filament", "$enc_datadir/printer") { + next if -d $dir; + if (!mkdir $dir) { + my $error = "Slic3r was unable to create its data directory at $dir ($!)."; + warn "$error\n"; + fatal_error(undef, $error); + } } # load settings @@ -161,22 +165,19 @@ sub catch_error { # static method accepting a wxWindow object as first parameter sub show_error { - my $self = shift; - my ($message) = @_; - Wx::MessageDialog->new($self, $message, 'Error', wxOK | wxICON_ERROR)->ShowModal; + my ($parent, $message) = @_; + Wx::MessageDialog->new($parent, $message, 'Error', wxOK | wxICON_ERROR)->ShowModal; } # static method accepting a wxWindow object as first parameter sub show_info { - my $self = shift; - my ($message, $title) = @_; - Wx::MessageDialog->new($self, $message, $title || 'Notice', wxOK | wxICON_INFORMATION)->ShowModal; + my ($parent, $message, $title) = @_; + Wx::MessageDialog->new($parent, $message, $title || 'Notice', wxOK | wxICON_INFORMATION)->ShowModal; } # static method accepting a wxWindow object as first parameter sub fatal_error { - my $self = shift; - $self->show_error(@_); + show_error(@_); exit 1; }