Permalink
Browse files

Change backtrace printer to use nqp::printfh and nqp::backtrace inste…

…ad of Parrot-specific methods
  • Loading branch information...
1 parent e60cfbe commit 81060d1093b2fb52e713172cb2d04ffe392861ce @sorear sorear committed Jun 17, 2013
Showing with 23 additions and 8 deletions.
  1. +5 −0 src/core/Backtrace.pm
  2. +18 −8 src/core/Exception.pm
@@ -28,7 +28,12 @@ my class Backtrace is List {
proto method new(|) {*}
multi method new(Exception $e, Int $offset = 0) {
+#?if parrot
self.new(nqp::getattr(nqp::decont($e), Exception, '$!ex').backtrace, $offset);
+#?endif
+#?if jvm
+ self.new(nqp::backtrace(nqp::getattr(nqp::decont($e), Exception, '$!ex')), $offset);
+#?endif
}
multi method new() {
View
@@ -205,14 +205,19 @@ do {
my $e := EXCEPTION($ex);
my Mu $err := nqp::getstderr();
+#?if parrot
if $e.is-compile-time || is_runtime($ex.backtrace) {
- $err.print: $e.gist;
- $err.print: "\n";
+#?endif
+#?if jvm
+ if $e.is-compile-time || is_runtime(nqp::backtrace($ex)) {
+#?endif
+ nqp::printfh($err, $e.gist);
+ nqp::printfh($err, "\n");
}
else {
- $err.print: "===SORRY!===\n";
- $err.print: $ex;
- $err.print: "\n";
+ nqp::printfh($err, "===SORRY!===\n");
+ nqp::printfh($err, $e.Str);
+ nqp::printfh($err, "\n");
}
$_() for nqp::hllize(@*END_PHASERS);
}
@@ -233,9 +238,14 @@ do {
if ($type == nqp::const::CONTROL_WARN) {
my Mu $err := nqp::getstderr();
my $msg = nqp::p6box_s(nqp::getmessage($ex));
- $err.print: $msg ?? "$msg" !! "Warning";
- $err.print: Backtrace.new($ex.backtrace, 0).nice(:oneline);
- $err.print: "\n";
+ nqp::printfh($err, $msg ?? "$msg" !! "Warning");
+#?if parrot
+ nqp::printfh($err, Backtrace.new($ex.backtrace, 0).nice(:oneline));
+#?endif
+#?if jvm
+ nqp::printfh($err, Backtrace.new(nqp::backtrace($ex), 0).nice(:oneline));
+#?endif
+ nqp::printfh($err, "\n");
my $resume := nqp::atkey($ex, 'resume');
if ($resume) {
$resume();

0 comments on commit 81060d1

Please sign in to comment.