Skip to content

Commit

Permalink
Correctly catch errors from _installPackage()
Browse files Browse the repository at this point in the history
  • Loading branch information
skh committed Apr 1, 2021
1 parent 7af1fa9 commit 166f76f
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions x-pack/plugins/fleet/server/services/epm/packages/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,29 +286,31 @@ async function installPackageFromRegistry({
const { paths, packageInfo } = await Registry.getRegistryPackage(pkgName, pkgVersion);

// try installing the package, if there was an error, call error handler and rethrow
try {
return _installPackage({
savedObjectsClient,
esClient,
installedPkg,
paths,
packageInfo,
installType,
installSource: 'registry',
}).then((assets) => {
// TODO: without the ts-ignore, TS complains about the type of the value of the returned InstallResult.status
// @ts-ignore
return _installPackage({
savedObjectsClient,
esClient,
installedPkg,
paths,
packageInfo,
installType,
installSource: 'registry',
})
.then((assets) => {
return { assets, status: 'installed', installType };
})
.catch(async (err: Error) => {
await handleInstallPackageFailure({
savedObjectsClient,
error: err,
pkgName,
pkgVersion,
installedPkg,
esClient,
});
return { error: err, installType };
});
} catch (e) {
await handleInstallPackageFailure({
savedObjectsClient,
error: e,
pkgName,
pkgVersion,
installedPkg,
esClient,
});
throw e;
}
} catch (e) {
return {
error: e,
Expand Down

0 comments on commit 166f76f

Please sign in to comment.