CantConvert improvements (#4926)

* CantConvert improvements

* cargo fmt
This commit is contained in:
Jonathan Moore
2022-03-24 07:04:31 -05:00
committed by GitHub
parent 5d5b02d8dc
commit ea7c8c237e
11 changed files with 45 additions and 20 deletions

View File

@ -112,6 +112,16 @@ pub enum ShellError {
#[diagnostic(code(nu::shell::cant_convert), url(docsrs))]
CantConvert(String, String, #[label("can't convert {1} to {0}")] Span),
// Identical to above, but with help
#[error("Can't convert to {0}.")]
#[diagnostic(code(nu::shell::cant_convert), url(docsrs), help("{3}"))]
CantConvertWithHelp(
String,
String,
#[label("can't convert {1} to {0}")] Span,
String,
),
#[error("{0} is not representable as a string.")]
#[diagnostic(
code(nu::shell::env_var_not_a_string),

View File

@ -16,7 +16,7 @@ impl Value {
match self {
Value::Int { val, .. } => Ok(*val),
x => Err(ShellError::CantConvert(
"rf64".into(),
"i64".into(),
x.get_type().to_string(),
self.span()?,
)),