Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

improve error handling and messaging #482

Merged
merged 2 commits into from
Sep 12, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/app/addons/rs/url.server.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ YUI.add('addon-rs-url', function(Y, NAME) {
*/
onGetMojitTypeDetails: function(evt) {
var ress = this.get('host').getResources(evt.args.env, evt.args.ctx, {type: 'mojit', name: evt.args.mojitType});

if (!ress || !ress[0]) {
throw new Error('Unable to compute assets root for mojit "' + evt.mojit.type + '". This usually happens when trying to run a mojit that does not exist.');
}

evt.mojit.assetsRoot = ress[0].url + '/assets';
},

Expand Down
6 changes: 4 additions & 2 deletions lib/store.server.js
Original file line number Diff line number Diff line change
Expand Up @@ -1413,7 +1413,9 @@ YUI.add('mojito-resource-store', function(Y, NAME) {
// The base will need to carry its ID with it.
spec.id = spec.base;
appConfig = this.getAppConfig(ctx);
base = appConfig.specs[spec.base];

// appConfig.specs might be undefined, for example in newly created apps
base = appConfig.specs && appConfig.specs[spec.base];

if (!base) {
// look in resources
Expand All @@ -1426,7 +1428,7 @@ YUI.add('mojito-resource-store', function(Y, NAME) {
}
}
if (!base) {
throw new Error('Unknown base of "' + spec.base + '"');
throw new Error('Unknown base "' + spec.base + '". You should have configured "' + spec.base + '" in application.json under specs or used "@' + spec.base + '" if you wanted to specify a mojit name.');
}

delete spec.base;
Expand Down
2 changes: 1 addition & 1 deletion lib/tests/autoload/store.server-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ YUI.add('mojito-store-server-tests', function(Y, NAME) {
var spec = { base: 'nonexistant' };
store.expandInstance(spec, {}, function(err, instance) {
A.isNotUndefined(err);
A.areSame('Unknown base of "nonexistant"', err.message);
A.areSame('Unknown base "nonexistant". You should have configured "nonexistant" in application.json under specs or used "@nonexistant" if you wanted to specify a mojit name.', err.message);
A.isUndefined(instance);
});
},
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/lib/test-store.server.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ YUI().use(
var spec = { base: 'nonexistant' };
store.expandInstance(spec, {}, function(err, instance) {
A.isNotUndefined(err);
A.areSame('Unknown base of "nonexistant"', err.message);
A.areSame('Unknown base "nonexistant". You should have configured "nonexistant" in application.json under specs or used "@nonexistant" if you wanted to specify a mojit name.', err.message);
A.isUndefined(instance);
});
},
Expand Down