Use ::pCatch(noop) instead of .catch(noop).
Avoid hiding programmer errors.
This commit is contained in:
parent
6406bb7fb6
commit
6aba73f970
@ -1,4 +1,7 @@
|
||||
import { noop } from '../utils'
|
||||
import {
|
||||
noop,
|
||||
pCatch
|
||||
} from '../utils'
|
||||
|
||||
export async function add ({
|
||||
host,
|
||||
@ -11,7 +14,7 @@ export async function add ({
|
||||
|
||||
if (autoConnect) {
|
||||
// Connect asynchronously, ignore any errors.
|
||||
this.connectXenServer(server.id).catch(noop)
|
||||
this.connectXenServer(server.id)::pCatch(noop)
|
||||
}
|
||||
|
||||
return server.id
|
||||
@ -96,7 +99,7 @@ set.params = {
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
export async function connect ({id}) {
|
||||
this.updateXenServer(id, {enabled: true}).catch(noop)
|
||||
this.updateXenServer(id, {enabled: true})::pCatch(noop)
|
||||
await this.connectXenServer(id)
|
||||
}
|
||||
|
||||
@ -113,7 +116,7 @@ connect.params = {
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
export async function disconnect ({id}) {
|
||||
this.updateXenServer(id, {enabled: false}).catch(noop)
|
||||
this.updateXenServer(id, {enabled: false})::pCatch(noop)
|
||||
await this.disconnectXenServer(id)
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ startsWith = require 'lodash.startswith'
|
||||
noop,
|
||||
parseSize,
|
||||
parseXml,
|
||||
pCatch,
|
||||
pFinally
|
||||
} = require '../utils'
|
||||
{isVmRunning: $isVMRunning} = require('../xapi')
|
||||
@ -277,7 +278,7 @@ delete_ = ({vm, delete_disks: deleteDisks}) ->
|
||||
@releaseLimitsInResourceSet(
|
||||
@computeVmResourcesUsage(vm),
|
||||
resourceSet
|
||||
).catch(noop)
|
||||
)::pCatch(noop)
|
||||
|
||||
return xapi.deleteVm(vm._xapiId, deleteDisks)
|
||||
|
||||
|
@ -9,6 +9,7 @@ import {
|
||||
import {
|
||||
addChecksumToReadStream,
|
||||
noop,
|
||||
pCatch,
|
||||
validChecksumOfReadStream
|
||||
} from '../utils'
|
||||
|
||||
@ -90,7 +91,7 @@ export default class RemoteHandlerAbstract {
|
||||
await eventToPromise(stream, 'readable')
|
||||
|
||||
if (stream.length === undefined) {
|
||||
stream.length = await this.getSize(file).catch(noop)
|
||||
stream.length = await this.getSize(file)::pCatch(noop)
|
||||
}
|
||||
|
||||
return stream
|
||||
@ -157,7 +158,7 @@ export default class RemoteHandlerAbstract {
|
||||
checksum = false
|
||||
} = {}) {
|
||||
if (checksum) {
|
||||
this._unlink(`${file}.checksum`).catch(noop)
|
||||
this._unlink(`${file}.checksum`)::pCatch(noop)
|
||||
}
|
||||
|
||||
return this._unlink(file)
|
||||
|
32
src/xapi.js
32
src/xapi.js
@ -381,7 +381,7 @@ export default class Xapi extends XapiBase {
|
||||
|
||||
return value === null
|
||||
? removal
|
||||
: removal.catch(noop).then(() => this.call(add, ref, name, prepareXapiParam(value)))
|
||||
: removal::pCatch(noop).then(() => this.call(add, ref, name, prepareXapiParam(value)))
|
||||
}
|
||||
}))
|
||||
}
|
||||
@ -861,7 +861,7 @@ export default class Xapi extends XapiBase {
|
||||
let ref
|
||||
try {
|
||||
ref = await this.call('VM.snapshot_with_quiesce', vm.$ref, nameLabel)
|
||||
this.addTag(ref, 'quiesce').catch(noop) // ignore any failures
|
||||
this.addTag(ref, 'quiesce')::pCatch(noop) // ignore any failures
|
||||
} catch (error) {
|
||||
if (
|
||||
error.code !== 'VM_SNAPSHOT_WITH_QUIESCE_NOT_SUPPORTED' &&
|
||||
@ -1064,7 +1064,7 @@ export default class Xapi extends XapiBase {
|
||||
|
||||
// Removes disks from the provision XML, we will create them by
|
||||
// ourselves.
|
||||
await this.call('VM.remove_from_other_config', vm.$ref, 'disks').catch(noop)
|
||||
await this.call('VM.remove_from_other_config', vm.$ref, 'disks')::pCatch(noop)
|
||||
|
||||
// Creates the VDIs and executes the initial steps of the
|
||||
// installation.
|
||||
@ -1216,14 +1216,14 @@ export default class Xapi extends XapiBase {
|
||||
vdi.VBDs.length < 2 ||
|
||||
every(vdi.$VBDs, vbd => vbd.VM === vm.$ref)
|
||||
) {
|
||||
return this._deleteVdi(vdi).catch(noop)
|
||||
return this._deleteVdi(vdi)::pCatch(noop)
|
||||
}
|
||||
console.error(`cannot delete VDI ${vdi.name_label} (from VM ${vm.name_label})`)
|
||||
}))
|
||||
}
|
||||
|
||||
await Promise.all(mapToArray(vm.$snapshots, snapshot => {
|
||||
return this.deleteVm(snapshot.$id, true).catch(noop)
|
||||
return this.deleteVm(snapshot.$id, true)::pCatch(noop)
|
||||
}))
|
||||
|
||||
await this.call('VM.destroy', vm.$ref)
|
||||
@ -1267,7 +1267,7 @@ export default class Xapi extends XapiBase {
|
||||
const taskRef = await this._createTask('VM Export', vm.name_label)
|
||||
if (snapshotRef) {
|
||||
this._watchTask(taskRef)::pFinally(() => {
|
||||
this.deleteVm(snapshotRef, true).catch(noop)
|
||||
this.deleteVm(snapshotRef, true)::pCatch(noop)
|
||||
})
|
||||
}
|
||||
|
||||
@ -1293,7 +1293,7 @@ export default class Xapi extends XapiBase {
|
||||
if (snapshotNameLabel) {
|
||||
this._setObjectProperties(vm, {
|
||||
nameLabel: snapshotNameLabel
|
||||
}).catch(noop)
|
||||
})::pCatch(noop)
|
||||
}
|
||||
|
||||
const baseVm = baseVmId && this.getObject(baseVmId)
|
||||
@ -1431,7 +1431,7 @@ export default class Xapi extends XapiBase {
|
||||
// 2. Delete all VBDs which may have been created by the import.
|
||||
await Promise.all(mapToArray(
|
||||
vm.$VBDs,
|
||||
vbd => this._deleteVbd(vbd).catch(noop)
|
||||
vbd => this._deleteVbd(vbd)::pCatch(noop)
|
||||
))
|
||||
|
||||
// 3. Create VDIs.
|
||||
@ -1510,7 +1510,7 @@ export default class Xapi extends XapiBase {
|
||||
])
|
||||
|
||||
if (deleteBase && baseVm) {
|
||||
this._deleteVm(baseVm, true).catch(noop)
|
||||
this._deleteVm(baseVm, true)::pCatch(noop)
|
||||
}
|
||||
|
||||
await Promise.all([
|
||||
@ -1604,7 +1604,7 @@ export default class Xapi extends XapiBase {
|
||||
if (onVmCreation) {
|
||||
this._waitObject(
|
||||
obj => obj && obj.current_operations && taskRef in obj.current_operations
|
||||
).then(onVmCreation).catch(noop)
|
||||
).then(onVmCreation)::pCatch(noop)
|
||||
}
|
||||
|
||||
const [ vmRef ] = await Promise.all([
|
||||
@ -1776,10 +1776,10 @@ export default class Xapi extends XapiBase {
|
||||
} finally {
|
||||
this._setObjectProperties(vm, {
|
||||
PV_bootloader: bootloader
|
||||
}).catch(noop)
|
||||
})::pCatch(noop)
|
||||
|
||||
forEach(bootables, ([ vbd, bootable ]) => {
|
||||
this._setObjectProperties(vbd, { bootable }).catch(noop)
|
||||
this._setObjectProperties(vbd, { bootable })::pCatch(noop)
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -1976,7 +1976,7 @@ export default class Xapi extends XapiBase {
|
||||
throw error
|
||||
}
|
||||
|
||||
await this.call('VBD.eject', cdDrive.$ref).catch(noop)
|
||||
await this.call('VBD.eject', cdDrive.$ref)::pCatch(noop)
|
||||
|
||||
// Retry.
|
||||
await this.call('VBD.insert', cdDrive.$ref, cd.$ref)
|
||||
@ -2015,7 +2015,7 @@ export default class Xapi extends XapiBase {
|
||||
}
|
||||
|
||||
async _deleteVbd (vbd) {
|
||||
await this._disconnectVbd(vbd).catch(noop)
|
||||
await this._disconnectVbd(vbd)::pCatch(noop)
|
||||
await this.call('VBD.destroy', vbd.$ref)
|
||||
}
|
||||
|
||||
@ -2023,7 +2023,7 @@ export default class Xapi extends XapiBase {
|
||||
async destroyVbdsFromVm (vmId) {
|
||||
await Promise.all(
|
||||
mapToArray(this.getObject(vmId).$VBDs, async vbd => {
|
||||
await this.disconnectVbd(vbd.$ref).catch(noop)
|
||||
await this.disconnectVbd(vbd.$ref)::pCatch(noop)
|
||||
return this.call('VBD.destroy', vbd.$ref)
|
||||
})
|
||||
)
|
||||
@ -2099,7 +2099,7 @@ export default class Xapi extends XapiBase {
|
||||
response.cancel = (cancel => () => {
|
||||
return new Promise(resolve => {
|
||||
resolve(cancel())
|
||||
}).then(() => task.catch(noop))
|
||||
}).then(() => task::pCatch(noop))
|
||||
})(response.cancel)
|
||||
response.task = task
|
||||
|
||||
|
@ -5,6 +5,7 @@ import {
|
||||
import {
|
||||
createRawObject,
|
||||
generateToken,
|
||||
pCatch,
|
||||
noop
|
||||
} from '../utils'
|
||||
|
||||
@ -166,7 +167,7 @@ export default class {
|
||||
if (!(
|
||||
token.expiration > Date.now()
|
||||
)) {
|
||||
this._tokens.remove(id).catch(noop)
|
||||
this._tokens.remove(id)::pCatch(noop)
|
||||
|
||||
throw new NoSuchAuthenticationToken(id)
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ import {
|
||||
forEach,
|
||||
mapToArray,
|
||||
noop,
|
||||
pCatch,
|
||||
pSettle,
|
||||
safeDateFormat
|
||||
} from '../utils'
|
||||
@ -151,7 +152,7 @@ export default class {
|
||||
// Once done, (asynchronously) remove the (now obsolete) local
|
||||
// base.
|
||||
if (localBaseUuid) {
|
||||
promise.then(() => srcXapi.deleteVm(localBaseUuid, true)).catch(noop)
|
||||
promise.then(() => srcXapi.deleteVm(localBaseUuid, true))::pCatch(noop)
|
||||
}
|
||||
|
||||
// (Asynchronously) Identify snapshot as future base.
|
||||
@ -159,7 +160,7 @@ export default class {
|
||||
return srcXapi._updateObjectMapProperty(srcVm, 'other_config', {
|
||||
[TAG_LAST_BASE_DELTA]: delta.vm.uuid
|
||||
})
|
||||
}).catch(noop)
|
||||
})::pCatch(noop)
|
||||
|
||||
return promise
|
||||
})()
|
||||
@ -306,7 +307,7 @@ export default class {
|
||||
const base = bases.pop()
|
||||
|
||||
// Remove old bases if exists.
|
||||
Promise.all(mapToArray(bases, base => xapi.deleteVdi(base.$id))).catch(noop)
|
||||
Promise.all(mapToArray(bases, base => xapi.deleteVdi(base.$id)))::pCatch(noop)
|
||||
|
||||
// It is strange to have no base but a full backup !
|
||||
// A full is necessary if it not exists backups or
|
||||
@ -340,8 +341,8 @@ export default class {
|
||||
])
|
||||
} catch (error) {
|
||||
// Remove new backup. (corrupt) and delete new vdi base.
|
||||
xapi.deleteVdi(currentSnapshot.$id).catch(noop)
|
||||
await handler.unlink(backupFullPath, { checksum: true }).catch(noop)
|
||||
xapi.deleteVdi(currentSnapshot.$id)::pCatch(noop)
|
||||
await handler.unlink(backupFullPath, { checksum: true })::pCatch(noop)
|
||||
|
||||
throw error
|
||||
}
|
||||
@ -440,7 +441,7 @@ export default class {
|
||||
const { newBaseId, backupDirectory, vdiFilename } = vdiBackup.value()
|
||||
|
||||
await xapi.deleteVdi(newBaseId)
|
||||
await handler.unlink(`${dir}/${backupDirectory}/${vdiFilename}`, { checksum: true }).catch(noop)
|
||||
await handler.unlink(`${dir}/${backupDirectory}/${vdiFilename}`, { checksum: true })::pCatch(noop)
|
||||
})
|
||||
)
|
||||
}
|
||||
@ -534,7 +535,7 @@ export default class {
|
||||
await handler.outputFile(infoPath, JSON.stringify(info, null, 2), {flag: 'wx'})
|
||||
} catch (e) {
|
||||
await Promise.all([
|
||||
handler.unlink(infoPath).catch(noop),
|
||||
handler.unlink(infoPath)::pCatch(noop),
|
||||
this._failedRollingDeltaVmBackup(xapi, handler, dir, fulFilledVdiBackups)
|
||||
])
|
||||
|
||||
@ -561,7 +562,7 @@ export default class {
|
||||
|
||||
// Remove xva file.
|
||||
// Version 0.0.0 (Legacy) Delta Backup.
|
||||
handler.unlink(`${dir}/${getDeltaBackupNameWithoutExt(backup)}.xva`).catch(noop)
|
||||
handler.unlink(`${dir}/${getDeltaBackupNameWithoutExt(backup)}.xva`)::pCatch(noop)
|
||||
})
|
||||
)
|
||||
}
|
||||
@ -575,7 +576,7 @@ export default class {
|
||||
await xapi.deleteVdi(oldBaseId)
|
||||
}
|
||||
})
|
||||
).catch(noop)
|
||||
)::pCatch(noop)
|
||||
|
||||
// Returns relative path.
|
||||
return `${dir}/${backupFormat}`
|
||||
|
@ -20,7 +20,8 @@ import {
|
||||
createRawObject,
|
||||
forEach,
|
||||
mapToArray,
|
||||
noop
|
||||
noop,
|
||||
pCatch
|
||||
} from '../utils'
|
||||
|
||||
// ===================================================================
|
||||
@ -89,16 +90,16 @@ export default class {
|
||||
.then(tokens => {
|
||||
forEach(tokens, token => {
|
||||
this._xo._tokens.remove(token.id)
|
||||
.catch(noop)
|
||||
::pCatch(noop)
|
||||
})
|
||||
})
|
||||
.catch(noop) // Ignore any failures.
|
||||
::pCatch(noop) // Ignore any failures.
|
||||
|
||||
// Remove the user from all its groups.
|
||||
forEach(user.groups, groupId => {
|
||||
this.getGroup(groupId)
|
||||
.then(group => this._removeUserFromGroup(id, group))
|
||||
.catch(noop) // Ignore any failures.
|
||||
::pCatch(noop) // Ignore any failures.
|
||||
})
|
||||
}
|
||||
|
||||
@ -232,7 +233,7 @@ export default class {
|
||||
forEach(group.users, userId => {
|
||||
this.getUser(userId)
|
||||
.then(user => this._removeGroupFromUser(id, user))
|
||||
.catch(noop) // Ignore any failures.
|
||||
::pCatch(noop) // Ignore any failures.
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@ import {
|
||||
isEmpty,
|
||||
isString,
|
||||
noop,
|
||||
pCatch,
|
||||
popProperty
|
||||
} from '../utils'
|
||||
import {
|
||||
@ -75,7 +76,7 @@ export default class {
|
||||
}
|
||||
|
||||
async unregisterXenServer (id) {
|
||||
this.disconnectXenServer(id).catch(noop)
|
||||
this.disconnectXenServer(id)::pCatch(noop)
|
||||
|
||||
if (!await this._servers.remove(id)) { // eslint-disable-line space-before-keywords
|
||||
throw new NoSuchXenServer(id)
|
||||
|
Loading…
Reference in New Issue
Block a user