better error handling
This commit is contained in:
parent
72c46447c1
commit
79189561c6
16
build.rs
16
build.rs
@ -29,7 +29,7 @@
|
||||
|
||||
use std::{
|
||||
io::{ Error, Write },
|
||||
process::{ Command, exit, Stdio },
|
||||
process::{ Command, Stdio },
|
||||
path::PathBuf,
|
||||
};
|
||||
|
||||
@ -51,11 +51,9 @@ fn main() -> Result<(), Error> {
|
||||
|
||||
let output = process.wait_with_output()?.stdout;
|
||||
|
||||
let headers = String::from_utf8(output).unwrap_or_else( |e| {
|
||||
Error::other(e.to_string());
|
||||
/* Exit with status 1 because we’re bootstrapping sysexits.h, silly! */
|
||||
exit(1);
|
||||
});
|
||||
let headers = String::from_utf8(output).map_err(|e| {
|
||||
Error::other(e.to_string())
|
||||
})?;
|
||||
|
||||
/* Split headers by spaces because cpp(1) returns more than one */
|
||||
for h in headers.split(' ') {
|
||||
@ -73,11 +71,9 @@ fn main() -> Result<(), Error> {
|
||||
.header(header)
|
||||
.parse_callbacks(Box::new(CargoCallbacks::new()))
|
||||
.generate()
|
||||
.expect("Unable to generate bindings.");
|
||||
.map_err(|e| Error::other(e.to_string()))?;
|
||||
|
||||
bindings
|
||||
.write_to_file(PathBuf::from("src/").join("lib.rs"))
|
||||
.expect("Couldn't write bindings!");
|
||||
bindings.write_to_file(PathBuf::from("src/").join("lib.rs"))?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user