Add additional span to IncorrectValue error (#10036)

This commit is contained in:
Jakub Žádník 2023-08-18 20:47:05 +03:00 committed by GitHub
parent cdf09abcc0
commit fb908df17d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 5 deletions

View File

@ -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 {

View File

@ -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 {

View File

@ -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,
}), }),
}, },
} }

View File

@ -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.