mirror of
https://github.com/nushell/nushell.git
synced 2024-11-25 09:53:43 +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)),
|
||||
_ => Err(ShellError::IncorrectValue {
|
||||
msg: "compression must be one of deflate or snappy".to_string(),
|
||||
span,
|
||||
val_span: span,
|
||||
call_span: span,
|
||||
}),
|
||||
}
|
||||
} else {
|
||||
|
@ -252,7 +252,10 @@ fn action(input: &Value, args: &Arguments, span: Span) -> Value {
|
||||
Value::Int { val: 0, span }
|
||||
}
|
||||
}
|
||||
Value::Date { val, .. } => {
|
||||
Value::Date {
|
||||
val,
|
||||
span: val_span,
|
||||
} => {
|
||||
if val
|
||||
< &FixedOffset::east_opt(0)
|
||||
.expect("constant")
|
||||
@ -267,7 +270,8 @@ fn action(input: &Value, args: &Arguments, span: Span) -> Value {
|
||||
Value::Error {
|
||||
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(),
|
||||
span
|
||||
val_span: *val_span,
|
||||
call_span: span,
|
||||
}),
|
||||
}
|
||||
} else {
|
||||
|
@ -275,7 +275,8 @@ fn action(
|
||||
Err(e) => Value::Error {
|
||||
error: Box::new(ShellError::IncorrectValue {
|
||||
msg: format!("Regex error: {e}"),
|
||||
span: find.span,
|
||||
val_span: find.span,
|
||||
call_span: head,
|
||||
}),
|
||||
},
|
||||
}
|
||||
|
@ -114,7 +114,9 @@ pub enum ShellError {
|
||||
IncorrectValue {
|
||||
msg: String,
|
||||
#[label = "{msg}"]
|
||||
span: Span,
|
||||
val_span: Span,
|
||||
#[label = "encountered here"]
|
||||
call_span: Span,
|
||||
},
|
||||
|
||||
/// This value cannot be used with this operator.
|
||||
|
Loading…
Reference in New Issue
Block a user