feat(xo-common/Error.is): apply predicate only on data

See #5644
This commit is contained in:
Julien Fontanet
2021-03-19 10:30:35 +01:00
parent 078f402819
commit 1e278bde92
3 changed files with 3 additions and 2 deletions

View File

@@ -33,6 +33,7 @@
>
> In case of conflict, the highest (lowest in previous list) `$version` wins.
- xo-common minor
- @xen-orchestra/fs patch
- xen-api minor
- xo-server patch

View File

@@ -19,7 +19,7 @@ class XoError extends BaseError {
const create = (code, getProps) => {
const factory = (...args) => new XoError({ ...getProps(...args), code })
factory.is = (error, predicate) => error.code === code && (predicate === undefined || iteratee(predicate)(error))
factory.is = (error, predicate) => error.code === code && (predicate === undefined || iteratee(predicate)(error.data))
return factory
}

View File

@@ -27,7 +27,7 @@ export const create = defer(async function ($defer, { name, size, sr, vm, bootab
break
} catch (error) {
if (!noSuchObject.is(error, { data: { id: resourceSet } })) {
if (!noSuchObject.is(error, { id: resourceSet })) {
throw error
}
}