1. Toby Inkster
  2. p5-type-tiny

Commits

Toby Inkster  committed fddcf8b

new multi-line exceptions only on Perl 5.8+ now

  • Participants
  • Parent commits be66e31
  • Branches default

Comments (0)

Files changed (1)

File lib/Type/Exception/Assertion.pm

View file
  • Ignore whitespace
 		: sprintf('%s did not pass type constraint', Type::Tiny::_dd($e->value))
 }
 
-sub to_string
+*to_string = sub
 {
 	my $e = shift;
+	my $msg = $e->message;
+	
+	my $c = $e->context;
+	$msg .= sprintf("at %s line %s", $c->{file}||'file?', $c->{line}||'NaN') if $c;
 	
 	my $explain = $e->explain;
-	my $msg     = $e->message;
-	
 	return $msg unless @{ $explain || [] };
 	
 	$msg .= "\n";
 	}
 	
 	return $msg;
-}
+} if $] >= 5.008;
 
 sub explain
 {