give ICE a proper error type
This commit is contained in:
parent
3c4877b059
commit
037ea618c7
|
@ -591,36 +591,25 @@ enum CompileError {
|
|||
|
||||
impl CompileError {
|
||||
fn to_shell_error(self, mut span: Option<Span>) -> ShellError {
|
||||
let ice = "internal compiler error: ";
|
||||
let message = match self {
|
||||
CompileError::RegisterOverflow => format!("{ice}register overflow"),
|
||||
CompileError::RegisterOverflow => format!("register overflow"),
|
||||
CompileError::RegisterUninitialized(reg_id) => {
|
||||
format!("{ice}register {reg_id} is uninitialized when used, possibly reused")
|
||||
format!("register {reg_id} is uninitialized when used, possibly reused")
|
||||
}
|
||||
CompileError::InvalidRedirectMode => {
|
||||
format!("{ice}invalid redirect mode: File should not be specified by commands")
|
||||
}
|
||||
CompileError::Garbage => {
|
||||
format!("{ice}encountered garbage, likely due to parse error")
|
||||
}
|
||||
CompileError::UnsupportedOperatorExpression => {
|
||||
format!("{ice}unsupported operator expression")
|
||||
"invalid redirect mode: File should not be specified by commands".into()
|
||||
}
|
||||
CompileError::Garbage => "encountered garbage, likely due to parse error".into(),
|
||||
CompileError::UnsupportedOperatorExpression => "unsupported operator expression".into(),
|
||||
CompileError::AccessEnvByInt(local_span) => {
|
||||
span = Some(local_span);
|
||||
format!("{ice}attempted access of $env by integer path")
|
||||
"attempted access of $env by integer path".into()
|
||||
}
|
||||
CompileError::Todo(msg) => {
|
||||
format!("{ice}TODO: {msg}")
|
||||
format!("TODO: {msg}")
|
||||
}
|
||||
};
|
||||
ShellError::GenericError {
|
||||
error: message,
|
||||
msg: "while compiling this code".into(),
|
||||
span,
|
||||
help: Some("this is a bug, please report it at https://github.com/nushell/nushell/issues/new along with the code you were compiling if able".into()),
|
||||
inner: vec![]
|
||||
}
|
||||
ShellError::IrCompileError { message, span }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1369,6 +1369,23 @@ On Windows, this would be %USERPROFILE%\AppData\Roaming"#
|
|||
help("Set XDG_CONFIG_HOME to an absolute path, or set it to an empty string to ignore it")
|
||||
)]
|
||||
InvalidXdgConfig { xdg: String, default: String },
|
||||
|
||||
/// An error occurred with the IR compiler.
|
||||
///
|
||||
/// ## Resolution
|
||||
///
|
||||
/// The IR compiler is in very early development, so code that can't be compiled is quite
|
||||
/// expected. If you think it should be working, please report it to us.
|
||||
#[error("internal compiler error: {message}")]
|
||||
#[diagnostic(
|
||||
code(nu::shell::ir_compile_error),
|
||||
help("this is a bug, please report it at https://github.com/nushell/nushell/issues/new along with the code you were compiling if able")
|
||||
)]
|
||||
IrCompileError {
|
||||
message: String,
|
||||
#[label = "while compiling this code"]
|
||||
span: Option<Span>,
|
||||
},
|
||||
}
|
||||
|
||||
// TODO: Implement as From trait
|
||||
|
|
Loading…
Reference in New Issue
Block a user