Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More informative error handling when connection string is ill-formed #75

Closed
fatuhoku opened this issue Mar 14, 2013 · 2 comments
Closed

Comments

@fatuhoku
Copy link

I tried to hack up database access quickly by writing something like this CoffeeScript, expecting the package to guide me through informative errors:

app.use orm.express '',
  define: (db) ->
    return

, I run into this:

TypeError: Cannot call method 'replace' of undefined
    at Object.exports.connect (<project>/node_modules/orm/lib/ORM.js:58:29)
    at Object.module.exports (<project>/node_modules/orm/lib/Express.js:9:6)
    at Object.exports.express (<project>/node_modules/orm/lib/ORM.js:20:30)

node-orm2 just blindly assumes that there is a colon to be matched in the connection string in ORM.js:58:

var proto  = opts.protocol.replace(/:$/, '');

but in fact, we mustn't assume the connection is valid all the time.

@dresende
Copy link
Owner

I'll change the db.connect to be more error prone and avoid throwing unexpected errors.

dresende added a commit that referenced this issue Mar 14, 2013
…me errors about missing protocol or database (#75)

Added a test with 3 possible error cases
dresende added a commit that referenced this issue Mar 14, 2013
@dresende
Copy link
Owner

I think these 2 errors already give you something. If you think there are more checks that should be done, feel free to reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants