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 helpful error for nonexistent DB #430

Open
cllns opened this issue Aug 8, 2017 · 2 comments
Open

More helpful error for nonexistent DB #430

cllns opened this issue Aug 8, 2017 · 2 comments
Assignees

Comments

@cllns
Copy link
Member

cllns commented Aug 8, 2017

 % b e rake
/Users/sean/.gem/ruby/2.3.3/gems/hanami-model-1.0.1/lib/hanami/model/configuration.rb:144:in `rescue in load!': PG::ConnectionBad: FATAL:  database "bookshelf_test" does not exist (Hanami::Model::Error)
	from /Users/sean/.gem/ruby/2.3.3/gems/hanami-model-1.0.1/lib/hanami/model/configuration.rb:134:in `load!'
	from /Users/sean/.gem/ruby/2.3.3/gems/hanami-model-1.0.1/lib/hanami/model.rb:79:in `load!'
	from /Users/sean/.gem/ruby/2.3.3/gems/hanami-1.0.0/lib/hanami/components/components.rb:83:in `block (2 levels) in <module:Components>'
	from /Users/sean/.gem/ruby/2.3.3/gems/hanami-1.0.0/lib/hanami/components/component.rb:44:in `call'
	from /Users/sean/.gem/ruby/2.3.3/gems/hanami-1.0.0/lib/hanami/components.rb:85:in `block (2 levels) in resolve'
	from /Users/sean/.gem/ruby/2.3.3/gems/concurrent-ruby-1.0.5/lib/concurrent/map.rb:133:in `block in fetch_or_store'
	from /Users/sean/.gem/ruby/2.3.3/gems/concurrent-ruby-1.0.5/lib/concurrent/map.rb:122:in `fetch'
	from /Users/sean/.gem/ruby/2.3.3/gems/concurrent-ruby-1.0.5/lib/concurrent/map.rb:132:in `fetch_or_store'
	from /Users/sean/.gem/ruby/2.3.3/gems/hanami-1.0.0/lib/hanami/components.rb:83:in `block in resolve'
	from /Users/sean/.gem/ruby/2.3.3/gems/hanami-1.0.0/lib/hanami/components.rb:82:in `each'
	from /Users/sean/.gem/ruby/2.3.3/gems/hanami-1.0.0/lib/hanami/components.rb:82:in `resolve'
	from /Users/sean/.gem/ruby/2.3.3/gems/hanami-1.0.0/lib/hanami/components/component.rb:138:in `resolve_requirements'
	from /Users/sean/.gem/ruby/2.3.3/gems/hanami-1.0.0/lib/hanami/components/component.rb:36:in `call'
	from /Users/sean/.gem/ruby/2.3.3/gems/hanami-1.0.0/lib/hanami/components.rb:85:in `block (2 levels) in resolve'
	from /Users/sean/.gem/ruby/2.3.3/gems/concurrent-ruby-1.0.5/lib/concurrent/map.rb:133:in `block in fetch_or_store'
	from /Users/sean/.gem/ruby/2.3.3/gems/concurrent-ruby-1.0.5/lib/concurrent/map.rb:122:in `fetch'
	from /Users/sean/.gem/ruby/2.3.3/gems/concurrent-ruby-1.0.5/lib/concurrent/map.rb:132:in `fetch_or_store'
	from /Users/sean/.gem/ruby/2.3.3/gems/hanami-1.0.0/lib/hanami/components.rb:83:in `block in resolve'
	from /Users/sean/.gem/ruby/2.3.3/gems/hanami-1.0.0/lib/hanami/components.rb:82:in `each'
	from /Users/sean/.gem/ruby/2.3.3/gems/hanami-1.0.0/lib/hanami/components.rb:82:in `resolve'
	from /Users/sean/.gem/ruby/2.3.3/gems/hanami-1.0.0/lib/hanami.rb:92:in `boot'
...

Instead of just:

 database "bookshelf_test" does not exist (Hanami::Model::Error)

Should we say something like:

 database "bookshelf_test" does not exist (Hanami::Model::Error)
 TIP: In order to create and migrate this database, run: `HANAMI_ENV=test bundle exec hanami db prepare`

(only show the HANAMI_ENV part if it's already equal to 'test')

Thoughts?? @hanami/core

@jodosha
Copy link
Member

jodosha commented Aug 8, 2017

@cllns yup 👍

@AlfonsoUceda
Copy link
Contributor

This happens too when you run the server and access localhost:2300, it only happens with postgresql and not with mysql and sqlite. So I think we need to rescue that exception in our error classes and create something like Hanami::Model::ConnectionError.

@cllns will you take care of this?

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

Successfully merging a pull request may close this issue.

3 participants