geddy / model

Datastore-agnostic ORM in JavaScript
265 stars 55 forks source link

Add clearer error message when a model can't be found #242

Closed OscarGodson closed 9 years ago

OscarGodson commented 9 years ago

Re: #240

First the error message I was getting was just "Cannot call method 'create' of undefined" trying to use "FamiliesUsers". This took me a awhile to figure out it was actually coming from inside of model's code, not mine. Then I wrongly assumed that model lazily loaded models by their file name.

model is nice because it's sort of magic in that it handles a ton of stuff for you like associations, pluralization and such so sometimes it's hard to know where the magic ends and when you need to be explicit. This error message should help by:

  1. Making it much more clear this is a custom error message, therefore not in your code, model's and
  2. reminding you to require the file if you forgot it or didn't know you needed to manually do it.
mde commented 9 years ago

This looks good. The failing test is only the v0.8 Node stuff, which has been removed in the release branch (and now in master too). Don't worry about that. You're a commiter, so go ahead and push the button on this one!