Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Misleading error message doesn't hint on how to fix the problem #30

Merged
merged 1 commit into from

2 participants

@francois

I thought this message was misleading. My real error was I had never called Sequel#connect, not that the database server was absent, unreachable or that the database doesn't exist. Actually, when I read the message the first time I started digging in my PostgreSQL instance to ensure the database and tables existed.

I can't find a spec that checks for that error. I actually removed the spec, and no specs failed. I don't see how this could be spec'd either.

Reproduction recipe:

require "rubygems"
require "sequel"
require "jdbc/postgres"  
class A < Sequel::Model(:a); end
Sequel::Error: No database associated with Sequel::Model
    from /Users/francois/.rvm/gems/jruby-1.6.0/gems/sequel-3.22.0/lib/sequel/model/base.rb:165:in `db'
    from /Users/francois/.rvm/gems/jruby-1.6.0/gems/sequel-3.22.0/lib/sequel/model/base.rb:271:in `inherited'
    from /Users/francois/.rvm/gems/jruby-1.6.0/gems/sequel-3.22.0/lib/sequel/model/associations.rb:696:in `inherited'
    from org/jruby/RubyClass.java:837:in `initialize'
    from /Users/francois/.rvm/gems/jruby-1.6.0/gems/sequel-3.22.0/lib/sequel/model.rb:43:in `Model'
    from (irb):5:in `evaluate'
    from org/jruby/RubyKernel.java:1087:in `eval'
    from /Users/francois/.rvm/rubies/jruby-1.6.0/lib/ruby/1.8/irb.rb:158:in `eval_input'
    from /Users/francois/.rvm/rubies/jruby-1.6.0/lib/ruby/1.8/irb.rb:271:in `signal_status'
    from /Users/francois/.rvm/rubies/jruby-1.6.0/lib/ruby/1.8/irb.rb:155:in `eval_input'
    from org/jruby/RubyKernel.java:1417:in `loop'
    from org/jruby/RubyKernel.java:1190:in `catch'
    from /Users/francois/.rvm/rubies/jruby-1.6.0/lib/ruby/1.8/irb.rb:154:in `eval_input'
    from /Users/francois/.rvm/rubies/jruby-1.6.0/lib/ruby/1.8/irb.rb:71:in `start'
    from org/jruby/RubyKernel.java:1190:in `catch'
    from /Users/francois/.rvm/rubies/jruby-1.6.0/lib/ruby/1.8/irb.rb:70:in `start'
    from /Users/francois/.rvm/rubies/jruby-1.6.0/bin/irb:17:in `(root)'
@jeremyevans
Owner

I don't think the error message is currently misleading, but you are right that it doesn't hint on how to fix the problem. I've merged the commit into my local repo and will push the changes up later today.

@jeremyevans jeremyevans merged commit f87103a into jeremyevans:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  lib/sequel/model/base.rb
View
2  lib/sequel/model/base.rb
@@ -162,7 +162,7 @@ def dataset=(ds)
def db
return @db if @db
@db = self == Model ? DATABASES.first : superclass.db
- raise(Error, "No database associated with #{self}") unless @db
+ raise(Error, "No database associated with #{self}: have you called Sequel#connect or #{self}#db= ?") unless @db
@db
end
Something went wrong with that request. Please try again.