diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index df126c76b..8250964ff 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -12,6 +12,7 @@ > Users must be able to say: “I had this issue, happy to know it's fixed” - [Plugin/auth-saml] Certificate input support multiline (PR [#6403](https://github.com/vatesfr/xen-orchestra/pull/6403)) +- [Start VM] Clearer error message when `NO_HOSTS_AVAILABLE` error is triggered [#6316](https://github.com/vatesfr/xen-orchestra/issues/6316) (PR [#6408](https://github.com/vatesfr/xen-orchestra/pull/6408)) ### Packages to release diff --git a/packages/xo-server/src/xapi/index.mjs b/packages/xo-server/src/xapi/index.mjs index df5153c6c..e09e990ce 100644 --- a/packages/xo-server/src/xapi/index.mjs +++ b/packages/xo-server/src/xapi/index.mjs @@ -882,16 +882,20 @@ export default class Xapi extends XapiBase { throw error } - throw new AggregateError( - await asyncMap(await this.call('host.get_all'), async hostRef => { - const hostNameLabel = await this.call('host.get_name_label', hostRef) - try { - await this.call('VM.assert_can_boot_here', vmRef, hostRef) - return `${hostNameLabel}: OK` - } catch (error) { - return `${hostNameLabel}: ${error.message}` - } - }) + throw Object.assign( + new AggregateError( + await asyncMap(await this.call('host.get_all'), async hostRef => { + const hostNameLabel = await this.call('host.get_name_label', hostRef) + try { + await this.call('VM.assert_can_boot_here', vmRef, hostRef) + return `${hostNameLabel}: OK` + } catch (error) { + return `${hostNameLabel}: ${error.message}` + } + }), + error.message + ), + { code: error.code, params: error.params } ) } } else {