diff --git a/crates/nu-plugin/src/plugin/interface/plugin.rs b/crates/nu-plugin/src/plugin/interface/plugin.rs index a01bdd49f9..3b8a51386f 100644 --- a/crates/nu-plugin/src/plugin/interface/plugin.rs +++ b/crates/nu-plugin/src/plugin/interface/plugin.rs @@ -817,10 +817,15 @@ impl PluginInterface { } } } - // If we fail to get a response - Err(ShellError::PluginFailedToDecode { - msg: "Failed to receive response to plugin call".into(), - }) + // If we fail to get a response, check for an error in the state first, and return it if + // set. This is probably a much more helpful error than 'failed to receive response' + if let Some(error) = self.state.error.get() { + Err(error.clone()) + } else { + Err(ShellError::PluginFailedToDecode { + msg: "Failed to receive response to plugin call".into(), + }) + } } /// Handle an engine call and write the response.