fix(core): pass unkown api error to webview (#1304)

This commit is contained in:
Noah Klayman
2021-02-27 22:03:28 -08:00
committed by GitHub
parent 0c691f40a3
commit adac93b9f1

View File

@@ -339,9 +339,20 @@ async fn on_message<A: ApplicationExt + 'static>(
Err(e) => Err(e),
};
if let Err(crate::Error::UnknownApi(_)) = response {
response = crate::plugin::extend_api(A::plugin_store(), &webview_manager, &message.inner)
.await
.map(|value| value.into());
match crate::plugin::extend_api(A::plugin_store(), &webview_manager, &message.inner).await {
Ok(value) => {
// If value is None, that means that no plugin matched the command
// and the UnknownApi error should be sent to the webview
// Otherwise, send the result of plugin handler
if value.is_some() {
response = Ok(value.into());
}
}
Err(e) => {
// A plugin handler was found but it failed
response = Err(e);
}
}
}
response
};