Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Perlito5 - improve error handling at compilation-time
  • Loading branch information
fglock committed Aug 30, 2012
1 parent 5ec800c commit 2ffd277
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
14 changes: 13 additions & 1 deletion perlito5.pl
Expand Up @@ -5461,6 +5461,9 @@ sub Perlito5::Grammar::Use::expand_use {
if (((($module_name eq 'strict') || ($module_name eq 'warnings')) || ($module_name eq 'feature'))) {
return ()
};
if (exists($Perlito_internal_module{$module_name})) {
($module_name = $Perlito_internal_module{$module_name})
};
((my $filename) = modulename_to_filename($module_name));
if ((filename_lookup($filename) eq 'done')) {
return ()
Expand Down Expand Up @@ -10230,7 +10233,16 @@ package Perlito5::Runtime;
else {
(my $comp_units);
if ($expand_use) {
($comp_units = Perlito5::Grammar::Use::add_comp_unit(Perlito5::Match::flat($m)))
(my $ok);
(do {
($comp_units = Perlito5::Grammar::Use::add_comp_unit(Perlito5::Match::flat($m)));
($ok = 1)
});
if (!($ok)) {
((my $error) = (${'@'} || 'Unknown error loading a module'));
warn($error);
exit(255)
}
}
else {
($comp_units = Perlito5::Match::flat($m))
Expand Down
4 changes: 4 additions & 0 deletions src5/lib/Perlito5/Grammar/Use.pm
Expand Up @@ -164,6 +164,10 @@ sub expand_use {
if $module_name eq 'strict'
|| $module_name eq 'warnings'
|| $module_name eq 'feature';

$module_name = $Perlito_internal_module{$module_name}
if exists $Perlito_internal_module{$module_name};

my $filename = modulename_to_filename($module_name);

return
Expand Down
12 changes: 11 additions & 1 deletion src5/util/perlito5.pl
Expand Up @@ -185,7 +185,17 @@ package Perlito;
else {
my $comp_units;
if ($expand_use) {
$comp_units = Perlito5::Grammar::Use::add_comp_unit(Perlito5::Match::flat($m))
my $ok;
eval {
$comp_units = Perlito5::Grammar::Use::add_comp_unit(Perlito5::Match::flat($m));
$ok = 1;
};
if ( !$ok ) {
my $error = $@
|| "Unknown error loading a module";
warn $error;
exit(255);
}
}
else {
$comp_units = Perlito5::Match::flat($m);
Expand Down

0 comments on commit 2ffd277

Please sign in to comment.