Skip to content

Commit

Permalink
tojsonl: better error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
jqnatividad committed Oct 7, 2022
1 parent 6f1dc4e commit 83b1191
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/cmd/tojsonl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
let schema_args = crate::cmd::schema::Args {
flag_enum_threshold: 3, // we only do three, as we're only inferring boolean based on enum
flag_strict_dates: false,
flag_pattern_columns: crate::select::SelectColumns::parse("").unwrap(),
flag_pattern_columns: crate::select::SelectColumns::parse("")?,
flag_dates_whitelist: "none".to_string(), // json doesn't have a date type, so don't infer dates
flag_prefer_dmy: false,
flag_stdout: false,
Expand Down Expand Up @@ -105,7 +105,10 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
// create a vec lookup about inferred field data types
let mut field_type_vec: Vec<String> = Vec::with_capacity(headers.len());
for (_field_name, field_def) in properties_map.iter() {
let field_map = field_def.as_object().unwrap();
let field_map = match field_def.as_object() {
Some(m) => m,
None => return fail!("Cannot create field map"),
};
let prelim_type = field_map.get("type").unwrap();
let field_values_enum = field_map.get("enum");

Expand Down

0 comments on commit 83b1191

Please sign in to comment.