Closed Syntaf closed 9 years ago
@cpjreynolds Can we get this ball rolling? Exception forwarding is a big feature rustty could benefit from I want to hear your input
Fantastic, this is extremely helpful, thank you! This will come in extremely useful during development so we can have proper error messages on panic instead of a blank screen. Merging, thanks again.
Proposed solution to https://github.com/cpjreynolds/rustty/issues/21
Ok, after days of looking into this subject I'm pretty sure there isn't a
nicernon-library solution. Here's a rundown:The Problem:
Solution:
EDIT:
stderr redirection through gag. gag doesn't introduce any new limiting factors in terms of dependencies, and solves the headache of redirecting stderr.
Terminal will now contain a handle to the stderr redirection, and during flush if a panic is detected the handle will spill it contents into a string and print that string after the clear finishes.
**Below is the old rant about finding a solution in the core library for this problem
There really isn't an intuitive solution like I had hoped, the biggest problem is that stderr has absolutely zero mechanisms that will allow me to leech, copy, or redirect. This leads to there being no way to actually see what's happening to stderr as well as us having no control of it. Along the road I've found some future notes
dup2
, but this is not cross-compatibleThe only solution I've found is to just detect a panic during drop ... and not flush the screen. It turns out rust is incredibly picky with allows you to even touch their output streams, from my research there is currently no method (in stable) of copying / redirecting stderr output.
If you guys have any input, I'd love to hear it. Maybe I'm wrong and I'm missing some super obvious solution (I hope I am)
EDIT: The rust IRC is recommending the use of libc to create a separate thread to pipe stderr, which sounds like it may work but I have no expertise in the area of libc; may take a look later
EDIT EDIT: Wait a second, on to something