rustdoc: Add some more error reporting for pandoc

This commit is contained in:
Brian Anderson 2012-03-06 14:19:10 -08:00
parent fc9b55d65f
commit b8c8e43381
1 changed files with 25 additions and 2 deletions

View File

@ -100,17 +100,40 @@ fn pandoc_writer(
os::close(pipe_out.out);
os::close(pipe_err.out);
os::close(pipe_in.out);
os::close(pipe_out.in);
os::close(pipe_err.in);
let stdout = result::get(task::try {||
readclose(pipe_out.in)
});
let stderr = result::get(task::try {||
readclose(pipe_err.in)
});
let status = run::waitpid(pid);
#debug("pandoc result: %i", status);
if status != 0 {
#error("pandoc-out: %s", stdout);
#error("pandoc-err: %s", stderr);
fail "pandoc failed";
}
}
}
fn readclose(fd: ctypes::fd_t) -> str {
import std::os;
import std::io;
// Copied from run::program_output
let file = os::fd_FILE(fd);
let reader = io::FILE_reader(file, false);
let buf = "";
while !reader.eof() {
let bytes = reader.read_bytes(4096u);
buf += str::from_bytes(bytes);
}
os::fclose(file);
ret buf;
}
fn generic_writer(process: fn~(markdown: str)) -> writer {
let ch = task::spawn_listener {|po: comm::port<writeinstr>|
let markdown = "";