mirror of
https://github.com/nushell/nushell
synced 2024-12-28 14:03:09 +00:00
use abbreviated string instead of debug string for DatetimeParseError
s (#12517)
Resolves #12444. Prevents debug string from being printed out. --------- Co-authored-by: sholderbach <sholderbach@users.noreply.github.com>
This commit is contained in:
parent
cc781a1ecd
commit
43814dcb0f
6 changed files with 32 additions and 20 deletions
|
@ -332,7 +332,7 @@ fn action(input: &Value, args: &Arguments, head: Span) -> Value {
|
|||
}
|
||||
None => Value::error(
|
||||
ShellError::DatetimeParseError {
|
||||
msg: input.to_debug_string(),
|
||||
msg: input.to_abbreviated_string(&nu_protocol::Config::default()),
|
||||
span: *span,
|
||||
},
|
||||
*span,
|
||||
|
@ -345,7 +345,7 @@ fn action(input: &Value, args: &Arguments, head: Span) -> Value {
|
|||
}
|
||||
None => Value::error(
|
||||
ShellError::DatetimeParseError {
|
||||
msg: input.to_debug_string(),
|
||||
msg: input.to_abbreviated_string(&nu_protocol::Config::default()),
|
||||
span: *span,
|
||||
},
|
||||
*span,
|
||||
|
|
|
@ -78,9 +78,11 @@ fn helper(value: Value, head: Span) -> Value {
|
|||
}
|
||||
Value::Date { val, .. } => Value::string(humanize_date(val), head),
|
||||
_ => Value::error(
|
||||
ShellError::DatetimeParseError {
|
||||
msg: value.to_debug_string(),
|
||||
span: head,
|
||||
ShellError::OnlySupportsThisInputType {
|
||||
exp_input_type: "date, string (that represents datetime), or nothing".into(),
|
||||
wrong_type: value.get_type().to_string(),
|
||||
dst_span: head,
|
||||
src_span: span,
|
||||
},
|
||||
head,
|
||||
),
|
||||
|
|
|
@ -112,9 +112,11 @@ fn helper(val: Value, head: Span) -> Value {
|
|||
}
|
||||
Value::Date { val, .. } => parse_date_into_table(val, head),
|
||||
_ => Value::error(
|
||||
ShellError::DatetimeParseError {
|
||||
msg: val.to_debug_string(),
|
||||
span: head,
|
||||
ShellError::OnlySupportsThisInputType {
|
||||
exp_input_type: "date, string (that represents datetime), or nothing".into(),
|
||||
wrong_type: val.get_type().to_string(),
|
||||
dst_span: head,
|
||||
src_span: span,
|
||||
},
|
||||
head,
|
||||
),
|
||||
|
|
|
@ -111,9 +111,11 @@ fn helper(val: Value, head: Span) -> Value {
|
|||
}
|
||||
Value::Date { val, .. } => parse_date_into_table(val, head),
|
||||
_ => Value::error(
|
||||
ShellError::DatetimeParseError {
|
||||
msg: val.to_debug_string(),
|
||||
span: head,
|
||||
ShellError::OnlySupportsThisInputType {
|
||||
exp_input_type: "date, string (that represents datetime), or nothing".into(),
|
||||
wrong_type: val.get_type().to_string(),
|
||||
dst_span: head,
|
||||
src_span: val_span,
|
||||
},
|
||||
head,
|
||||
),
|
||||
|
|
|
@ -115,9 +115,11 @@ fn helper(value: Value, head: Span, timezone: &Spanned<String>) -> Value {
|
|||
_to_timezone(dt.with_timezone(dt.offset()), timezone, head)
|
||||
}
|
||||
_ => Value::error(
|
||||
ShellError::DatetimeParseError {
|
||||
msg: value.to_debug_string(),
|
||||
span: head,
|
||||
ShellError::OnlySupportsThisInputType {
|
||||
exp_input_type: "date, string (that represents datetime), or nothing".into(),
|
||||
wrong_type: value.get_type().to_string(),
|
||||
dst_span: head,
|
||||
src_span: val_span,
|
||||
},
|
||||
head,
|
||||
),
|
||||
|
|
|
@ -153,9 +153,11 @@ fn format_helper(value: Value, formatter: &str, formatter_span: Span, head_span:
|
|||
}
|
||||
}
|
||||
_ => Value::error(
|
||||
ShellError::DatetimeParseError {
|
||||
msg: value.to_debug_string(),
|
||||
span: head_span,
|
||||
ShellError::OnlySupportsThisInputType {
|
||||
exp_input_type: "date, string (that represents datetime)".into(),
|
||||
wrong_type: value.get_type().to_string(),
|
||||
dst_span: head_span,
|
||||
src_span: value.span(),
|
||||
},
|
||||
head_span,
|
||||
),
|
||||
|
@ -174,9 +176,11 @@ fn format_helper_rfc2822(value: Value, span: Span) -> Value {
|
|||
}
|
||||
}
|
||||
_ => Value::error(
|
||||
ShellError::DatetimeParseError {
|
||||
msg: value.to_debug_string(),
|
||||
span,
|
||||
ShellError::OnlySupportsThisInputType {
|
||||
exp_input_type: "date, string (that represents datetime)".into(),
|
||||
wrong_type: value.get_type().to_string(),
|
||||
dst_span: span,
|
||||
src_span: val_span,
|
||||
},
|
||||
span,
|
||||
),
|
||||
|
|
Loading…
Reference in a new issue