Skip to content

Commit

Permalink
better error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert committed Nov 13, 2015
1 parent ae95b80 commit a5f537d
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions lib/strategy/EnrichClientFromRemoteConfigStrategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,14 @@ function EnrichClientFromRemoteConfigStrategy (clientFactory) {
EnrichClientFromRemoteConfigStrategy.prototype._resolveApplicationByHref = function (client, config, href, cb) {
client.getApplication(href, function (err, app) {
if (err) {
// TODO: If 404 then give the user a more valuable error, e.g. stating that the application doesn't exist.
cb(err);
if(err.status === 404){
cb(new Error(
'The provided application could not be found.\n\n' +
'The provided application href was: ' + href + '\n'
));
}else{
cb(err);
}
} else {
config.application = app;
cb(null, app);
Expand All @@ -38,7 +44,10 @@ EnrichClientFromRemoteConfigStrategy.prototype._resolveApplicationByName = funct
cb(name === app.name);
}, function (app) {
if (!app) {
cb(new Error('Application not found: "' + name + '"'));
cb(new Error(
'The provided application could not be found.\n\n' +
'The provided application name was: ' + name + '\n'
));
} else {
config.application = app;
cb(null, app);
Expand All @@ -63,7 +72,10 @@ EnrichClientFromRemoteConfigStrategy.prototype._resolveDefaultApplication = func
config.application = userApplications[0];
cb(null, userApplications[0]);
} else {
cb(new Error('No application found.'));
cb(new Error(
'Could not automatically resolve a Stormpath Application. \n\n'+
'Please specify your Stormpath Application in your configuration.\n'
));
}
});
};
Expand Down

0 comments on commit a5f537d

Please sign in to comment.