Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Don't leak out non-Panda exceptions.

This fixes emmentaler. It's also a part of my experiment to use Failures
where I usually used Exceptions. Please bear with me.
  • Loading branch information...
commit 4dc0da582136d22e6a97255c924e8a815bc596f7 1 parent 815fab5
@tadzik authored
View
24 lib/Panda.pm
@@ -79,17 +79,24 @@ class Panda {
method install(Panda::Project $bone, $nodeps,
$notests, $isdep as Bool) {
+ my $cwd = cwd;
my $dir = tmpdir();
self.announce('fetching', $bone);
unless $bone.metainfo<source-url> {
die X::Panda.new($bone.name, 'fetch', 'source-url meta info missing')
}
- $.fetcher.fetch($bone.metainfo<source-url>, $dir);
+ unless $_ = $.fetcher.fetch($bone.metainfo<source-url>, $dir) {
+ die X::Panda.new($bone.name, 'fetch', $_)
+ }
self.announce('building', $bone);
- $.builder.build($dir);
+ unless $_ = $.builder.build($dir) {
+ die X::Panda.new($bone.name, 'build', $_)
+ }
unless $notests {
self.announce('testing', $bone);
- $.tester.test($dir) unless $notests;
+ unless $_ = $.tester.test($dir) {
+ die X::Panda.new($bone.name, 'test', $_)
+ }
}
self.announce('installing', $bone);
$.installer.install($dir);
@@ -98,20 +105,20 @@ class Panda {
$.ecosystem.project-set-state($bone, $s);
self.announce('success', $bone);
+ chdir $cwd;
rm_rf $dir;
CATCH {
- when X::Panda {
- $_.module = $bone.name;
- rm_rf $dir;
- $_.throw;
- }
+ chdir $cwd;
+ rm_rf $dir;
}
}
method get-deps(Panda::Project $bone) {
my @bonedeps = $bone.dependencies.grep(*.defined).map({
$.ecosystem.get-project($_)
+ or die X::Panda.new($bone.name, 'resolve',
+ "Dependency $_ is not present in the module ecosystem")
}).grep({
$.ecosystem.project-get-state($_) == Panda::Project::State::absent
});
@@ -139,6 +146,7 @@ class Panda {
}
my $bone = $.ecosystem.get-project($proj);
if not $bone {
+ sub die($m) { X::Panda.new($proj, 'resolve', $m).throw }
my $suggestion = $.ecosystem.suggest-project($proj);
die "Project $proj not found in the ecosystem. Maybe you meant $suggestion?" if $suggestion;
die "Project $proj not found in the ecosystem";
View
3  lib/Panda/Builder.pm
@@ -86,12 +86,13 @@ method build($where) {
say "Compiling $file";
shell "$*EXECUTABLE_NAME --target=pir "
~ "--output=$dest $file"
- and die "Failed building $file";
+ and fail "Failed building $file";
}
1;
}
1;
};
+ return True;
}
# vim: ft=perl6
View
5 lib/Panda/Common.pm
@@ -36,7 +36,10 @@ class X::Panda is Exception {
has $.stage;
has $.description;
- method new($module, $stage, $description) {
+ method new($module, $stage, $description is copy) {
+ if $description ~~ Failure {
+ $description = $description.exception.message
+ }
self.bless(*, :$module, :$stage, :$description)
}
View
9 lib/Panda/Fetcher.pm
@@ -5,20 +5,22 @@ use Shell::Command;
method fetch($from, $to) {
given $from {
when /\.git$/ {
- git-fetch $from, $to;
+ return git-fetch $from, $to;
}
when *.IO.d {
local-fetch $from, $to;
}
default {
- die "Unable to handle source '$from'"
+ fail "Unable to handle source '$from'"
}
}
+ return True;
}
sub git-fetch($from, $to) {
shell "git clone -q $from \"$to\""
- and die "Failed cloning git repository '$from'"
+ and fail "Failed cloning git repository '$from'";
+ return True;
}
sub local-fetch($from, $to) {
@@ -30,6 +32,7 @@ sub local-fetch($from, $to) {
next if $_.IO ~~ :d;
$_.IO.copy("$where/{$_.name}");
}
+ return True;
}
# vim: ft=perl6
View
3  lib/Panda/Tester.pm
@@ -6,10 +6,11 @@ method test($where, :$prove-command = 'prove') {
if 't'.IO ~~ :d {
withp6lib {
my $c = "$prove-command -e $*EXECUTABLE_NAME -r t/";
- shell $c and die "Tests failed";
+ shell $c and fail "Tests failed";
}
}
};
+ return True;
}
# vim: ft=perl6

0 comments on commit 4dc0da5

Please sign in to comment.
Something went wrong with that request. Please try again.