Skip to content

Commit

Permalink
feat(controller): remove if/else for controller model and rely on try…
Browse files Browse the repository at this point in the history
… catch
  • Loading branch information
dylanfoster committed Nov 18, 2017
1 parent 53feabf commit c536c56
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions src/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,22 +97,20 @@ class Controller {
*/
registry.inject(this, "service:store", "store");

if (this.modelNameLookup) {
try {
/**
* The model class that belongs to this controller. If none could be found
* this will be undefined.
*
* @property internalModel
* @type {Object}
*/
registry.inject(this, `model:${this.modelNameLookup}`, "internalModel");
} catch (err) {
registry.lookup("service:logger").debug({
error: err,
controller: this.name
}, "failed to load model");
}
try {
/**
* The model class that belongs to this controller. If none could be found
* this will be undefined.
*
* @property internalModel
* @type {Object}
*/
registry.inject(this, `model:${this.modelNameLookup}`, "internalModel");
} catch (err) {
registry.lookup("service:logger").debug({
error: err,
controller: this.name
}, "failed to load model");
}
}

Expand Down

0 comments on commit c536c56

Please sign in to comment.