diff --git a/crates/nu-command/src/conversions/into/record.rs b/crates/nu-command/src/conversions/into/record.rs index c049658ece..17b809546a 100644 --- a/crates/nu-command/src/conversions/into/record.rs +++ b/crates/nu-command/src/conversions/into/record.rs @@ -183,12 +183,12 @@ fn into_record( Value::Record { cols, vals, span } } Value::Record { cols, vals, span } => Value::Record { cols, vals, span }, - other => Value::Error { - error: ShellError::UnsupportedInput( + other => { + return Err(ShellError::UnsupportedInput( "'into record' does not support this input".into(), other.span().unwrap_or(call.head), - ), - }, + )) + } }; Ok(res.into_pipeline_data()) } diff --git a/crates/nu-command/src/filesystem/save.rs b/crates/nu-command/src/filesystem/save.rs index bafbefc50c..d448ecf315 100644 --- a/crates/nu-command/src/filesystem/save.rs +++ b/crates/nu-command/src/filesystem/save.rs @@ -91,17 +91,12 @@ impl Command for Save { let mut file = match file { Ok(file) => file, Err(err) => { - return Ok(PipelineData::Value( - Value::Error { - error: ShellError::GenericError( - "Permission denied".into(), - err.to_string(), - Some(arg_span), - None, - Vec::new(), - ), - }, + return Err(ShellError::GenericError( + "Permission denied".into(), + err.to_string(), + Some(arg_span), None, + Vec::new(), )); } }; @@ -117,17 +112,12 @@ impl Command for Save { match std::fs::File::create(stderr_path) { Ok(file) => Some(file), Err(err) => { - return Ok(PipelineData::Value( - Value::Error { - error: ShellError::GenericError( - "Permission denied".into(), - err.to_string(), - Some(stderr_span), - None, - Vec::new(), - ), - }, + return Err(ShellError::GenericError( + "Permission denied".into(), + err.to_string(), + Some(stderr_span), None, + Vec::new(), )) } } diff --git a/crates/nu-command/src/network/fetch.rs b/crates/nu-command/src/network/fetch.rs index ed2f5542cb..3ba3c76126 100644 --- a/crates/nu-command/src/network/fetch.rs +++ b/crates/nu-command/src/network/fetch.rs @@ -135,17 +135,12 @@ impl Command for SubCommand { Err(err) => { let arg_span = call.get_named_arg("output").expect("arg should exist").span; - return Ok(PipelineData::Value( - Value::Error { - error: ShellError::GenericError( - "Permission denied".into(), - err.to_string(), - Some(arg_span), - None, - Vec::new(), - ), - }, + return Err(ShellError::GenericError( + "Permission denied".into(), + err.to_string(), + Some(arg_span), None, + Vec::new(), )); } }; diff --git a/crates/nu-command/src/system/registry_query.rs b/crates/nu-command/src/system/registry_query.rs index a46a4ccd3c..dd8e5c3016 100644 --- a/crates/nu-command/src/system/registry_query.rs +++ b/crates/nu-command/src/system/registry_query.rs @@ -146,16 +146,13 @@ fn registry_query( } .into_pipeline_data()) } - Err(_) => Ok(Value::Error { - error: ShellError::GenericError( - "Unable to find registry key/value".to_string(), - format!("Registry value: {} was not found", value.item), - Some(value.span), - None, - Vec::new(), - ), - } - .into_pipeline_data()), + Err(_) => Err(ShellError::GenericError( + "Unable to find registry key/value".to_string(), + format!("Registry value: {} was not found", value.item), + Some(value.span), + None, + Vec::new(), + )), } } None => Ok(Value::nothing(Span::test_data()).into_pipeline_data()),