mirror of
https://github.com/nushell/nushell.git
synced 2024-11-22 08:23:24 +01:00
Add additional span to IncorrectValue error (#10036)
This commit is contained in:
parent
cdf09abcc0
commit
fb908df17d
@ -65,7 +65,8 @@ fn get_compression(call: &Call) -> Result<Option<AvroCompression>, ShellError> {
|
|||||||
"deflate" => Ok(Some(AvroCompression::Deflate)),
|
"deflate" => Ok(Some(AvroCompression::Deflate)),
|
||||||
_ => Err(ShellError::IncorrectValue {
|
_ => Err(ShellError::IncorrectValue {
|
||||||
msg: "compression must be one of deflate or snappy".to_string(),
|
msg: "compression must be one of deflate or snappy".to_string(),
|
||||||
span,
|
val_span: span,
|
||||||
|
call_span: span,
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -252,7 +252,10 @@ fn action(input: &Value, args: &Arguments, span: Span) -> Value {
|
|||||||
Value::Int { val: 0, span }
|
Value::Int { val: 0, span }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Value::Date { val, .. } => {
|
Value::Date {
|
||||||
|
val,
|
||||||
|
span: val_span,
|
||||||
|
} => {
|
||||||
if val
|
if val
|
||||||
< &FixedOffset::east_opt(0)
|
< &FixedOffset::east_opt(0)
|
||||||
.expect("constant")
|
.expect("constant")
|
||||||
@ -267,7 +270,8 @@ fn action(input: &Value, args: &Arguments, span: Span) -> Value {
|
|||||||
Value::Error {
|
Value::Error {
|
||||||
error: Box::new(ShellError::IncorrectValue {
|
error: Box::new(ShellError::IncorrectValue {
|
||||||
msg: "DateTime out of range for timestamp: 1677-09-21T00:12:43Z to 2262-04-11T23:47:16".to_string(),
|
msg: "DateTime out of range for timestamp: 1677-09-21T00:12:43Z to 2262-04-11T23:47:16".to_string(),
|
||||||
span
|
val_span: *val_span,
|
||||||
|
call_span: span,
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -275,7 +275,8 @@ fn action(
|
|||||||
Err(e) => Value::Error {
|
Err(e) => Value::Error {
|
||||||
error: Box::new(ShellError::IncorrectValue {
|
error: Box::new(ShellError::IncorrectValue {
|
||||||
msg: format!("Regex error: {e}"),
|
msg: format!("Regex error: {e}"),
|
||||||
span: find.span,
|
val_span: find.span,
|
||||||
|
call_span: head,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,9 @@ pub enum ShellError {
|
|||||||
IncorrectValue {
|
IncorrectValue {
|
||||||
msg: String,
|
msg: String,
|
||||||
#[label = "{msg}"]
|
#[label = "{msg}"]
|
||||||
span: Span,
|
val_span: Span,
|
||||||
|
#[label = "encountered here"]
|
||||||
|
call_span: Span,
|
||||||
},
|
},
|
||||||
|
|
||||||
/// This value cannot be used with this operator.
|
/// This value cannot be used with this operator.
|
||||||
|
Loading…
Reference in New Issue
Block a user