diff --git a/src/api.js b/src/api.js index 36711b0f2..7245987bf 100644 --- a/src/api.js +++ b/src/api.js @@ -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) } diff --git a/src/xo.js b/src/xo.js index 3d6976a14..c0daa2713 100644 --- a/src/xo.js +++ b/src/xo.js @@ -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 && (