Adding endpoint missing exception

This commit is contained in:
Chris Cowan 2015-09-18 16:14:56 -07:00
parent a52895bf3f
commit b2e83dcf5d

View file

@ -6,8 +6,9 @@ module.exports = (client) => {
if (req.headers.authorization) {
_.set(params, 'headers.authorization', req.headers.authorization);
}
return _.get(client, endpoint)
.call(client, params)
const api = _.get(client, endpoint);
if (!api) throw new Error(`callWithRequest called with an invalid endpoint: ${endpoint}`);
return api.call(client, params)
.catch((err) => {
if (err.status === 401) {
const options = { realm: 'Authorization Required' };