Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'clearer-errors' into develop

  • Loading branch information...
commit 005551708496f13099a397cdb292b6243ab6204b 2 parents 0b935cd + 33084fe
@aljimenez aljimenez authored
View
5 lib/app/addons/rs/yui.js
@@ -600,6 +600,11 @@ YUI.add('addon-rs-yui', function(Y, NAME) {
var store = this.get('host');
this._captureYUIModuleDetails(res);
+
+ if (!res.yui) {
+ // Do not add YUI resources that failed while capturing details.
+ return new Y.Do.Halt();
+ }
},
View
3  lib/app/autoload/action-context.common.js
@@ -322,7 +322,8 @@ YUI.add('mojito-action-context', function(Y, NAME) {
actionFunction = '__call';
} else {
// If there is still no joy then die
- error = new Error("No method '" + command.action + "' on controller type '" + command.instance.type + "'");
+ error = new Error('Action "' + this.action + '" not defined by the controller named "'
+ + this.instance.controller + '" of the "' + this.type + '" mojit.');
error.code = 404;
throw error;
}
View
26 lib/app/autoload/dispatch.server.js
@@ -72,11 +72,8 @@ YUI.add('mojito-dispatcher', function (Y, NAME) {
store: this.store
});
} catch (e) {
- Y.log('Error from dispatch on instance \'' +
- (command.instance.id || '@' + command.instance.type) +
- '\':', 'error', NAME);
- Y.log(e.message, 'error', NAME);
- Y.log(e.stack, 'error', NAME);
+ Y.log('Error dispatching \'' +
+ (command.instance.id || '@' + command.instance.type) + '\': \n' + e.stack, 'error', NAME);
adapter.error(e);
}
// HookSystem::StartBlock
@@ -137,35 +134,36 @@ YUI.add('mojito-dispatcher', function (Y, NAME) {
store.expandInstance(command.instance, command.context,
function (err, instance) {
+ var errorMessage;
// HookSystem::StartBlock
Y.mojito.hooks.hook('dispatch', adapter.hook, 'end', command);
// HookSystem::EndBlock
if (err || !instance || !instance.controller) {
-
- adapter.error(new Error('Cannot expand instance [' + (command.instance.base || '@' +
- command.instance.type) + '], or instance.controller is undefined'));
+ errorMessage = 'Error expanding instance for "' +
+ (command.instance.id || command.instance.base || command.instance.type) + '"';
+ Y.log(errorMessage + (err ? ': \n' + err.stack :
+ instance && !instance.controller ? ': no valid controller found in the "' + instance.type + '" mojit' : ''), 'error', NAME);
+ adapter.error(new Error(errorMessage));
return;
-
}
// We replace the given instance with the expanded instance.
command.instance = instance;
if (!Y.mojito.controllers[instance.controller]) {
+ errorMessage = 'Invalid controller, named "' + instance.controller + '", in the "' + command.instance.type + '" mojit';
// the controller was not found, we should halt
- adapter.error(new Error('Invalid controller name [' +
- command.instance.controller + '] for mojit [' +
- command.instance.type + '].'));
+ Y.log(errorMessage + '. The controller does not define its actions under Y.namespace(\'mojito.controllers\')[\'' +
+ instance.controller + '\']', 'error', NAME);
+ adapter.error(new Error(errorMessage));
} else {
// dispatching AC
my._createActionContext(command, adapter);
}
-
});
}
-
};
}, '0.1.0', {requires: [
View
12 lib/app/autoload/store.server.js
@@ -586,6 +586,10 @@ YUI.add('mojito-resource-store', function(Y, NAME) {
spec.config = {};
}
+ if (!spec.type) {
+ return cb(new Error('Instance is missing a mojit type.'));
+ }
+
// type details
try {
typeDetails = this.getMojitTypeDetails(env, ctx, spec.type);
@@ -658,7 +662,7 @@ YUI.add('mojito-resource-store', function(Y, NAME) {
// if lazyLangs is on then determine the closetLang for this mojit and add the corresponding lang resources
// if they havent been added already.
- if (this.lazyLangs) {
+ if (this._unloadedLangs[mojitType]) {
closestLang = Y.mojito.util.findClosestLang(ctx.lang, this._unloadedLangs[mojitType]);
newModules = this._loadMojitLangs(mojitType, closestLang) || newModules;
}
@@ -1532,7 +1536,7 @@ YUI.add('mojito-resource-store', function(Y, NAME) {
* You most often don't want to call this directly, but instead to hook
* into it using the AOP mechanism of `Y.Plugin.Base`:
*
- * this.beforeHostMethod('parseResourceVersion', this._myParseResource, this);
+ * this.beforeHostMethod('addResourceVersion', this._myAddResourceVersion, this);
*
* @method addResourceVersion
* @param {object} res the resource version
@@ -1648,6 +1652,10 @@ YUI.add('mojito-resource-store', function(Y, NAME) {
ress = this._mojitRVs[type];
+ if (!ress) {
+ throw new Error('Cannot find the "' + type + '" mojit. Make sure "' + type + '" exists in the application.');
+ }
+
this._mojitDetails[type] = {};
for (r = 0; r < ress.length; r++) {
View
2  lib/output-handler.server.js
@@ -54,7 +54,7 @@ OutputHandler.prototype = {
size,
memDebug = {};
- this.logger.log('done', 'info', NAME);
+ this.logger.log('done', 'mojito', NAME);
this._readMeta(meta);
this._writeHeaders();
if (!data ||
View
3  tests/unit/lib/app/autoload/test-action-context.common.js
@@ -745,6 +745,7 @@ YUI().use('mojito-action-context', 'test', function (Y) {
instance: {
id: 'id',
type: 'TypeGeneral',
+ controller: 'GeneralController',
acAddons: [],
views: {}
}
@@ -764,7 +765,7 @@ YUI().use('mojito-action-context', 'test', function (Y) {
error = err;
}
A.isNotUndefined(error);
- A.areSame("No method 'index' on controller type 'TypeGeneral'", error.message.toString());
+ A.areSame('Action "index" not defined by the controller named "GeneralController" of the "TypeGeneral" mojit.', error.message.toString());
},
'test controller __call': function() {
Please sign in to comment.
Something went wrong with that request. Please try again.