Better message when a object param is not found.

This commit is contained in:
Julien Fontanet 2015-05-28 11:40:56 +02:00
parent 4d3dfa1dca
commit 35bf7dc484
2 changed files with 15 additions and 19 deletions

View File

@ -147,28 +147,24 @@ function resolveParams (method, params) {
const isAdmin = this.user.hasPermission('admin')
const promises = []
try {
forEach(resolve, ([param, types], key) => {
const id = params[param]
if (id === undefined) {
return
}
forEach(resolve, ([param, types], key) => {
const id = params[param]
if (id === undefined) {
return
}
const object = this.getObject(params[param], types)
const object = this.getObject(params[param], types)
// This parameter has been handled, remove it.
delete params[param]
// This parameter has been handled, remove it.
delete params[param]
// Register this new value.
params[key] = object
// Register this new value.
params[key] = object
if (!isAdmin) {
promises.push(checkAuthorization.call(this, userId, object))
}
})
} catch (error) {
throw new NoSuchObject()
}
if (!isAdmin) {
promises.push(checkAuthorization.call(this, userId, object))
}
})
return Bluebird.all(promises).return(params)
}

View File

@ -414,7 +414,7 @@ export default class Xo extends EventEmitter {
const obj = all[key] || byRef[key]
if (!obj) {
throw new NoSuchObject(key)
throw new NoSuchObject(key, type)
}
if (type != null && (