Skip to content

Commit

Permalink
standardize error messages to have : instead of - in front of error d…
Browse files Browse the repository at this point in the history
…etail
  • Loading branch information
jqnatividad committed Oct 28, 2022
1 parent 99d5e35 commit 3482e1d
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/cmd/enumerate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
} else if copy_operation {
let current_header = match String::from_utf8(headers[copy_index].to_vec()) {
Ok(s) => s,
Err(e) => return fail_clierror!("Could not parse cell as utf-8! - {e}"),
Err(e) => return fail_clierror!("Could not parse cell as utf-8!: {e}"),
};
headers.push_field(format!("{current_header}_copy").as_bytes());
} else {
Expand Down
6 changes: 3 additions & 3 deletions src/cmd/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,14 +406,14 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
let header_name: HeaderName =
match HeaderName::from_lowercase(k.to_lowercase().as_bytes()) {
Ok(h) => h,
Err(e) => return fail_clierror!("Invalid header name - {e}"),
Err(e) => return fail_clierror!("Invalid header name: {e}"),
};

// allocate new String for header value to put into map
let v: String = String::from(vals[1].trim());
let header_val: HeaderValue = match HeaderValue::from_str(v.as_str()) {
Ok(v) => v,
Err(e) => return fail_clierror!("Invalid header value - {e}"),
Err(e) => return fail_clierror!("Invalid header value: {e}"),
};

map.append(header_name, header_val);
Expand Down Expand Up @@ -633,7 +633,7 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
}
final_response = match serde_json::from_str(&intermediate_redis_value) {
Ok(r) => r,
Err(e)=> return fail_clierror!("Cannot deserialize Redis cache value. Try flushing the Redis cache with --flushdb - {e}"),
Err(e)=> return fail_clierror!("Cannot deserialize Redis cache value. Try flushing the Redis cache with --flushdb: {e}"),
};
if !args.flag_cache_error && final_response.status_code != 200 {
let key = format!(
Expand Down
6 changes: 3 additions & 3 deletions src/cmd/fetchpost.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,14 +374,14 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
let header_name: HeaderName =
match HeaderName::from_lowercase(k.to_lowercase().as_bytes()) {
Ok(h) => h,
Err(e) => return fail_clierror!("Invalid header name - {e}"),
Err(e) => return fail_clierror!("Invalid header name: {e}"),
};

// allocate new String for header value to put into map
let v: String = String::from(vals[1].trim());
let header_val: HeaderValue = match HeaderValue::from_str(v.as_str()) {
Ok(v) => v,
Err(e) => return fail_clierror!("Invalid header value - {e}"),
Err(e) => return fail_clierror!("Invalid header value: {e}"),
};

map.append(header_name, header_val);
Expand Down Expand Up @@ -603,7 +603,7 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
}
final_response = match serde_json::from_str(&intermediate_redis_value) {
Ok(r) => r,
Err(e)=> return fail_clierror!("Cannot deserialize Redis cache value. Try flushing the Redis cache with --flushdb - {e}"),
Err(e)=> return fail_clierror!("Cannot deserialize Redis cache value. Try flushing the Redis cache with --flushdb: {e}"),
};
if !args.flag_cache_error && final_response.status_code != 200 {
let key = format!(
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/jsonl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
}
let human_idx = rowidx + 1; // not zero based, for readability
return fail_clierror!(
r#"Could not parse line {human_idx} as JSON! - {e}
r#"Could not parse line {human_idx} as JSON!: {e}
Use `--ignore-errors` option to skip malformed input lines.
Use `tojsonl` command to convert _to_ jsonl instead of _from_ jsonl."#,
);
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ pub fn run(argv: &[&str]) -> CliResult<()> {

let schema_pretty = match serde_json::to_string_pretty(&schema) {
Ok(s) => s,
Err(e) => return fail_clierror!("Cannot prettify schema json - {e}"),
Err(e) => return fail_clierror!("Cannot prettify schema json: {e}"),
};

if args.flag_stdout {
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/searchset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ fn read_regexset(filename: &String) -> io::Result<Vec<String>> {
Ok(f) => BufReader::new(f).lines().collect(),
Err(e) => Err(io::Error::new(
io::ErrorKind::NotFound,
format!("Cannot open regexset file {filename} - {e}"),
format!("Cannot open regexset file {filename}: {e}"),
)),
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/cmd/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ fn init_date_inference(
match INFER_DATE_FLAGS.set(vec![true; headers.len()]) {
Ok(_) => (),
Err(e) => {
return fail_format!("Cannot init date inference flags for ALL fields - {e:?}")
return fail_format!("Cannot init date inference flags for ALL fields: {e:?}")
}
};
} else {
Expand All @@ -392,13 +392,13 @@ fn init_date_inference(
}
match INFER_DATE_FLAGS.set(infer_date_flags) {
Ok(_) => (),
Err(e) => return fail_format!("Cannot init date inference flags - {e:?}"),
Err(e) => return fail_format!("Cannot init date inference flags: {e:?}"),
};
}
} else {
match INFER_DATE_FLAGS.set(vec![false; headers.len()]) {
Ok(_) => (),
Err(e) => return fail_format!("Cannot init empty date inference flags - {e:?}"),
Err(e) => return fail_format!("Cannot init empty date inference flags: {e:?}"),
};
}
Ok(())
Expand Down
6 changes: 3 additions & 3 deletions src/cmd/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -854,13 +854,13 @@ fn load_json(uri: &str) -> Result<String, String> {
{
Ok(c) => c,
Err(e) => {
return fail_format!("Cannot build reqwest client - {e}.");
return fail_format!("Cannot build reqwest client: {e}.");
}
};

match client.get(url).send() {
Ok(response) => response.text().unwrap_or_default(),
Err(e) => return fail_format!("Cannot read JSON at url {url} - {e}."),
Err(e) => return fail_format!("Cannot read JSON at url {url}: {e}."),
}
}
path => {
Expand All @@ -871,7 +871,7 @@ fn load_json(uri: &str) -> Result<String, String> {
.read_to_string(&mut buffer)
.unwrap_or_default();
}
Err(e) => return fail_format!("Cannot read JSON file {path} - {e}."),
Err(e) => return fail_format!("Cannot read JSON file {path}: {e}."),
}
buffer
}
Expand Down
4 changes: 2 additions & 2 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ pub fn qsv_check_for_update() -> Result<bool, String> {
Some(fs) => fs.to_string_lossy().into_owned(),
None => return fail!("Can't get the exec stem name"),
},
Err(e) => return fail_format!("Can't get the exec path - {e}"),
Err(e) => return fail_format!("Can't get the exec path: {e}"),
};

winfo!("Checking GitHub for updates...");
Expand Down Expand Up @@ -658,7 +658,7 @@ fn send_hwsurvey(
.build()
{
Ok(c) => c,
Err(e) => return fail_format!("Cannot build hw_survey reqwest client - {e}"),
Err(e) => return fail_format!("Cannot build hw_survey reqwest client: {e}"),
};

match client
Expand Down

0 comments on commit 3482e1d

Please sign in to comment.