Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
move PRE/POST error message logic to the error class; trim condition …
…text
  • Loading branch information
moritz committed Mar 18, 2012
1 parent d1505ae commit 924712d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
6 changes: 2 additions & 4 deletions src/Perl6/World.pm
Expand Up @@ -1254,10 +1254,8 @@ class Perl6::World is HLL::World {
PAST::Var.new( :name($sym), :scope('lexical_6model') ));
}
elsif $phaser eq 'PRE' || $phaser eq 'POST' {
my $what := self.add_string_constant(
$phaser eq 'PRE' ?? 'Precondition' !! 'Postcondition'
);
$what.named('what');
my $what := self.add_string_constant($phaser);
$what.named('phaser');
my $condition := self.add_string_constant(~$/<blorst>);
$condition.named('condition');

Expand Down
7 changes: 4 additions & 3 deletions src/core/Exception.pm
Expand Up @@ -498,12 +498,13 @@ my class X::Package::Stubbed does X::Comp {
}

my class X::Phaser::PrePost is Exception {
has $.what = 'Precondition';
has $.phaser = 'PRE';
has $.condition;
method message {
my $what = $.phaser eq 'PRE' ?? 'Precondition' !! 'Postcondition';
$.condition.defined
?? "$.what '$.condition' failed"
!! "$.what failed";
?? "$what '$.condition.trim()' failed"
!! "$what failed";
}
}

Expand Down

0 comments on commit 924712d

Please sign in to comment.