this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

style(errors): unify error message prefixes across job and backends

+23 -23
+2 -2
src/backends/stream.rs
··· 25 25 } 26 26 let path = &paths[0]; 27 27 if path.is_dir() { 28 - bail!("{name} does not operate on directories; specify a file instead."); 28 + bail!("{name} does not operate on directories; specify a file instead"); 29 29 } 30 30 let size = std::fs::metadata(path)?.len(); 31 31 let reader: Box<dyn Read + Send> = Box::new(BufReader::new(File::open(path)?)); ··· 43 43 if let CmprssOutput::Path(path) = output 44 44 && path.is_dir() 45 45 { 46 - bail!("{name} does not operate on directories; specify an output file instead."); 46 + bail!("{name} does not operate on directories; specify an output file instead"); 47 47 } 48 48 Ok(()) 49 49 }
+5 -5
src/backends/tar.rs
··· 78 78 match input { 79 79 CmprssInput::Path(paths) => { 80 80 if paths.len() != 1 { 81 - bail!("tar extraction expects a single archive file"); 81 + bail!("tar extraction expects exactly one archive file"); 82 82 } 83 83 let file = File::open(&paths[0])?; 84 84 let mut archive = Archive::new(file); ··· 109 109 CmprssOutput::Writer(mut writer) => match input { 110 110 CmprssInput::Path(paths) => { 111 111 if paths.len() != 1 { 112 - bail!("tar extraction expects a single archive file"); 112 + bail!("tar extraction expects exactly one archive file"); 113 113 } 114 114 let mut file = File::open(&paths[0])?; 115 115 io::copy(&mut file, &mut writer)?; ··· 131 131 let reader: Box<dyn Read> = match input { 132 132 CmprssInput::Path(paths) => { 133 133 if paths.len() != 1 { 134 - bail!("tar listing expects a single archive file"); 134 + bail!("tar listing expects exactly one archive file"); 135 135 } 136 136 Box::new(File::open(&paths[0])?) 137 137 } ··· 164 164 } else if path.is_dir() { 165 165 archive.append_dir_all(path.file_name().unwrap(), path.as_path())?; 166 166 } else { 167 - bail!("unsupported file type for tar compression"); 167 + bail!("tar does not support this file type"); 168 168 } 169 169 } 170 170 } ··· 176 176 archive.append_file("archive", &mut temp_file)?; 177 177 } 178 178 CmprssInput::Reader(_) => { 179 - bail!("Cannot tar a reader input directly"); 179 + bail!("tar does not accept an in-memory reader input"); 180 180 } 181 181 } 182 182 Ok(archive.finish()?)
+6 -6
src/backends/zip.rs
··· 42 42 let base = path.parent().unwrap_or(&path); 43 43 add_directory(&mut zip_writer, base, &path)?; 44 44 } else { 45 - bail!("unsupported file type for zip compression"); 45 + bail!("zip does not support this file type"); 46 46 } 47 47 } 48 48 } ··· 52 52 io::copy(&mut pipe, &mut zip_writer)?; 53 53 } 54 54 CmprssInput::Reader(_) => { 55 - bail!("Cannot zip a reader input"); 55 + bail!("zip does not accept an in-memory reader input"); 56 56 } 57 57 } 58 58 ··· 112 112 match input { 113 113 CmprssInput::Path(paths) => { 114 114 if paths.len() != 1 { 115 - bail!("zip extraction expects a single archive file"); 115 + bail!("zip extraction expects exactly one archive file"); 116 116 } 117 117 let file = File::open(&paths[0])?; 118 118 let mut archive = ZipArchive::new(file)?; ··· 134 134 } 135 135 CmprssInput::Reader(_) => { 136 136 bail!( 137 - "Cannot extract from a reader input for zip (requires seekable input)" 137 + "zip extraction does not accept an in-memory reader input (requires seekable input)" 138 138 ) 139 139 } 140 140 } ··· 143 143 CmprssOutput::Writer(mut writer) => match input { 144 144 CmprssInput::Path(paths) => { 145 145 if paths.len() != 1 { 146 - bail!("zip extraction expects a single archive file"); 146 + bail!("zip extraction expects exactly one archive file"); 147 147 } 148 148 let mut file = File::open(&paths[0])?; 149 149 io::copy(&mut file, &mut writer)?; ··· 169 169 match input { 170 170 CmprssInput::Path(paths) => { 171 171 if paths.len() != 1 { 172 - bail!("zip listing expects a single archive file"); 172 + bail!("zip listing expects exactly one archive file"); 173 173 } 174 174 let archive = ZipArchive::new(File::open(&paths[0])?)?; 175 175 for name in archive.file_names() {
+10 -10
src/job.rs
··· 97 97 if !std::io::stdin().is_terminal() && !args.ignore_pipes && !args.ignore_stdin { 98 98 return Ok(CmprssInput::Pipe(std::io::stdin())); 99 99 } 100 - bail!("No specified input"); 100 + bail!("No input specified"); 101 101 } 102 102 103 103 /// Whether we can send the output to stdout (piped, and the user hasn't ··· 225 225 let input_path = get_input_filename(input)?; 226 226 match action { 227 227 Some(Action::Compress) => { 228 - let c = compressor.ok_or_else(|| anyhow!("Must specify a compressor"))?; 228 + let c = compressor.ok_or_else(|| anyhow!("Could not determine compressor to use"))?; 229 229 Ok((c, Action::Compress)) 230 230 } 231 231 Some(Action::Extract) => { 232 232 let c = compressor 233 233 .or_else(|| get_compressor_from_filename(input_path)) 234 - .ok_or_else(|| anyhow!("Must specify a compressor"))?; 234 + .ok_or_else(|| anyhow!("Could not determine compressor to use"))?; 235 235 Ok((c, Action::Extract)) 236 236 } 237 237 // List is handled by the short-circuit at the top of get_job and ··· 249 249 None => { 250 250 // The input has to be something we can identify as an archive. 251 251 let c = get_compressor_from_filename(input_path) 252 - .ok_or_else(|| anyhow!("Must specify a compressor"))?; 252 + .ok_or_else(|| anyhow!("Could not determine compressor to use"))?; 253 253 Ok((c, Action::Extract)) 254 254 } 255 255 }, ··· 276 276 Some(Action::Extract) => { 277 277 if let CmprssInput::Path(paths) = input { 278 278 if paths.len() != 1 { 279 - bail!("Expected a single archive to extract"); 279 + bail!("Expected exactly one input archive"); 280 280 } 281 281 *compressor = get_compressor_from_filename(paths.first().unwrap()); 282 282 } ··· 288 288 *action = Some(Action::Extract); 289 289 if compressor.is_none() { 290 290 bail!( 291 - "Couldn't determine how to extract {:?}", 291 + "Could not determine compressor for {:?}", 292 292 paths.first().unwrap() 293 293 ); 294 294 } ··· 306 306 }); 307 307 } else { 308 308 if paths.len() != 1 { 309 - bail!("Expected a single input file for piping to stdout"); 309 + bail!("Expected exactly one input file when writing to stdout"); 310 310 } 311 311 *compressor = get_compressor_from_filename(paths.first().unwrap()); 312 312 if compressor.is_some() { 313 313 *action = Some(Action::Extract); 314 314 } else { 315 - bail!("Can't guess compressor to use"); 315 + bail!("Could not determine compressor to use"); 316 316 } 317 317 } 318 318 } ··· 332 332 if compressor.is_some() { 333 333 *action = Some(Action::Compress); 334 334 } else { 335 - bail!("Can't guess compressor to use"); 335 + bail!("Could not determine compressor to use"); 336 336 } 337 337 } 338 338 } ··· 354 354 match input { 355 355 CmprssInput::Path(paths) => match paths.first() { 356 356 Some(path) => Ok(path), 357 - None => bail!("error: no input specified"), 357 + None => bail!("No input specified"), 358 358 }, 359 359 CmprssInput::Pipe(_) => Ok(Path::new("archive")), 360 360 CmprssInput::Reader(_) => Ok(Path::new("piped_data")),