Skip to content

Commit

Permalink
Test to ensure that creator is valid
Browse files Browse the repository at this point in the history
Providing a better error message is always useful
  • Loading branch information
forivall committed Sep 15, 2014
1 parent 1742bca commit 0139cc4
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/core/store.coffee
Expand Up @@ -102,6 +102,9 @@ module.exports = class kb.Store
return obj if creator.models_only
return observable if observable = @find(obj, creator)

unless _.isFunction(creator.create or creator)
throw new Error "Invalid factory for \"#{options.path}\""

observable = kb.ignore =>
options = _.defaults({store: @, creator: creator}, options) # set our own creator so we can register ourselves above
observable = if creator.create then creator.create(obj, options) else new creator(obj, options)
Expand Down

1 comment on commit 0139cc4

@forivall
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I forgot that I have commit access and thought I was creating a fork. This problem cost me ~30 minutes, writing this commit took 5.

Please sign in to comment.