Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[Core] Update Parrot.try_report to take a list of alternate handles t…

…o use for stderr, stdout and stdin
  • Loading branch information...
commit b8c454ce8163caedc08026696f55e316bfb1dbe6 1 parent 627b65e
@Whiteknight authored
Showing with 20 additions and 6 deletions.
  1. +20 −6 src/core/Parrot.winxed
View
26 src/core/Parrot.winxed
@@ -45,18 +45,32 @@ namespace Rosella.Parrot
}
// Execute a function. Catch any exceptions and print the message and
- // backtrace out to a specified handle. If no handle is specified,
- // use stdout.
- function try_report(var sub, var handle = null)
+ // backtrace out to a specified handle. Swap out the standard handles,
+ // if alternatives are provided. Return whatever values the function
+ // returns
+ function try_report(var sub, var handles = null)
{
- if (handle == null)
- handle = getstdout();
+ var out = null;
+ if (handles != null && exists handles["stderr"])
+ out = handles["stderr"];
+ else
+ out = getstdout();
+ if (handles != null)
+ handles = Rosella.IO.swap_handles(handles);
+
+ var p;
+ var n;
try {
- sub();
+ :(p [slurpy], n [slurpy,named]) = sub();
} catch (e) {
var fmt = Rosella.Parrot.exception_formatter();
handle.print(fmt.format_default(e));
}
+
+ if (handles != null)
+ Rosella.IO.swap_handles(handles);
+
+ return p:[flat], n:[flat,named];
}
// private routine. Format backtrace information into an array of
Please sign in to comment.
Something went wrong with that request. Please try again.