Skip to content

Commit 8cdbfdc

Browse files
Fix incompatible result types via map_err
1 parent cd18440 commit 8cdbfdc

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

capnpc/src/codegen.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1859,7 +1859,8 @@ pub fn generate_code<T>(mut inp: T, out_dir: &::std::path::Path) -> ::capnp::Res
18591859
let requested = ::std::path::PathBuf::from(requested_file.get_filename()?);
18601860
filepath.push(requested);
18611861
if let Some(parent) = filepath.parent() {
1862-
::std::fs::create_dir_all(parent)?;
1862+
::std::fs::create_dir_all(parent)
1863+
.map_err(|err| ::capnp::Error::failed(err.to_string()))?;
18631864
}
18641865

18651866
let root_name = path_to_stem_string(&filepath)?.replace("-", "_");
@@ -1878,12 +1879,13 @@ pub fn generate_code<T>(mut inp: T, out_dir: &::std::path::Path) -> ::capnp::Res
18781879
// would not include `filepath`.
18791880
match ::std::fs::File::create(&filepath) {
18801881
Ok(ref mut writer) => {
1881-
writer.write_all(text.as_bytes())?;
1882+
writer.write_all(text.as_bytes())
1883+
.map_err(|err| ::capnp::Error::failed(err.to_string()))?;
18821884
}
18831885
Err(e) => {
18841886
let _ = writeln!(&mut ::std::io::stderr(),
18851887
"could not open file {:?} for writing: {}", filepath, e);
1886-
return Err(e.into());
1888+
return Err(::capnp::Error::failed(e.to_string()));
18871889
}
18881890
}
18891891
}

capnpc/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ pub enum RustEdition {
7878
}
7979

8080
fn run_command(mut command: ::std::process::Command, path: &PathBuf) -> ::capnp::Result<()> {
81-
let mut p = command.spawn()?;
81+
let mut p = command.spawn().map_err(|err| capnp::Error::failed(err.to_string()))?;
8282
crate::codegen::generate_code(p.stdout.take().unwrap(), path.as_path())?;
83-
let exit_status = p.wait()?;
83+
let exit_status = p.wait().map_err(|err| ::capnp::Error::failed(err.to_string()))?;
8484
if !exit_status.success() {
8585
Err(::capnp::Error::failed(format!(
8686
"Non-success exit status: {}",

0 commit comments

Comments
 (0)