forked from tforgione/md2pdf
Move some unsafe code and add error implementations
This commit is contained in:
parent
c0bc67d9ca
commit
cb90c6a4ad
23
src/main.rs
23
src/main.rs
|
@ -58,8 +58,27 @@ fn main() {
|
||||||
unwrap!(output.write(tex.as_bytes()), "couldn't write output file");
|
unwrap!(output.write(tex.as_bytes()), "couldn't write output file");
|
||||||
},
|
},
|
||||||
Some("pdf") => {
|
Some("pdf") => {
|
||||||
let data = unwrap!(markdown_to_pdf(content), "error while compiling latex, this is most likely a bug");
|
match markdown_to_pdf(content) {
|
||||||
unwrap!(output.write(&data), "couldn't write output file");
|
Ok(data) => {
|
||||||
|
match output.write(&data) {
|
||||||
|
Ok(_) => {
|
||||||
|
exit(0);
|
||||||
|
},
|
||||||
|
Err(error) => {
|
||||||
|
eprintln!(
|
||||||
|
"error while writing file: {}", error
|
||||||
|
);
|
||||||
|
exit(1);
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Err(error) => {
|
||||||
|
eprintln!(
|
||||||
|
"error while compiling latex: {}", error.description()
|
||||||
|
);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
Some(ext) => {
|
Some(ext) => {
|
||||||
eprintln!("unknown file format ({}) for output: {}", ext, output_path.display());
|
eprintln!("unknown file format ({}) for output: {}", ext, output_path.display());
|
||||||
|
|
Loading…
Reference in New Issue