mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 17:45:03 +02:00
Convert PluginFailedToLoad to named fields (#11124)
# Description Part of #10700 # User-Facing Changes None # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting N/A
This commit is contained in:
@ -454,11 +454,16 @@ impl EngineState {
|
||||
// Updating the signatures plugin file with the added signatures
|
||||
self.plugin_signatures
|
||||
.as_ref()
|
||||
.ok_or_else(|| ShellError::PluginFailedToLoad("Plugin file not found".into()))
|
||||
.ok_or_else(|| ShellError::PluginFailedToLoad {
|
||||
msg: "Plugin file not found".into(),
|
||||
})
|
||||
.and_then(|plugin_path| {
|
||||
// Always create the file, which will erase previous signatures
|
||||
std::fs::File::create(plugin_path.as_path())
|
||||
.map_err(|err| ShellError::PluginFailedToLoad(err.to_string()))
|
||||
std::fs::File::create(plugin_path.as_path()).map_err(|err| {
|
||||
ShellError::PluginFailedToLoad {
|
||||
msg: err.to_string(),
|
||||
}
|
||||
})
|
||||
})
|
||||
.and_then(|mut plugin_file| {
|
||||
// Plugin definitions with parsed signature
|
||||
@ -510,11 +515,15 @@ impl EngineState {
|
||||
// information when nushell starts
|
||||
format!("register {file_name} {shell_str} {signature}\n\n")
|
||||
})
|
||||
.map_err(|err| ShellError::PluginFailedToLoad(err.to_string()))
|
||||
.map_err(|err| ShellError::PluginFailedToLoad {
|
||||
msg: err.to_string(),
|
||||
})
|
||||
.and_then(|line| {
|
||||
plugin_file
|
||||
.write_all(line.as_bytes())
|
||||
.map_err(|err| ShellError::PluginFailedToLoad(err.to_string()))
|
||||
plugin_file.write_all(line.as_bytes()).map_err(|err| {
|
||||
ShellError::PluginFailedToLoad {
|
||||
msg: err.to_string(),
|
||||
}
|
||||
})
|
||||
})
|
||||
.and_then(|_| {
|
||||
plugin_file.flush().map_err(|err| {
|
||||
|
@ -736,9 +736,9 @@ pub enum ShellError {
|
||||
/// ## Resolution
|
||||
///
|
||||
/// This is a fairly generic error. Refer to the specific error message for further details.
|
||||
#[error("Plugin failed to load: {0}")]
|
||||
#[error("Plugin failed to load: {msg}")]
|
||||
#[diagnostic(code(nu::shell::plugin_failed_to_load))]
|
||||
PluginFailedToLoad(String),
|
||||
PluginFailedToLoad { msg: String },
|
||||
|
||||
/// A message from a plugin failed to encode.
|
||||
///
|
||||
|
Reference in New Issue
Block a user