Skip to content

Commit

Permalink
Showing a better config error message
Browse files Browse the repository at this point in the history
Previously we just showed a message saying that config was not defined. This
shows a better error message that can help developers fix the problem. Also,
the error message can be overriden.
  • Loading branch information
David Davis committed May 20, 2013
1 parent 19e4ae5 commit a9c0cc1
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions lib/runcible/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,13 @@ def self.config=(conf={})
:logging => {}
}.merge(conf)
end

def self.config
@@config

def self.config
if defined?(@@config)
@@config
else
raise Runcible::ConfigurationUndefinedError, Runcible::ConfigurationUndefinedError.message
end
end

def self.call(method, path, options={})
Expand Down Expand Up @@ -209,4 +213,12 @@ def self.generate_log_message
end

end

class ConfigurationUndefinedError < StandardError

def self.message
# override me to change the error message
"Configuration not set. Runcible::Base.config= must be called before Runcible::Base.config."
end
end
end

0 comments on commit a9c0cc1

Please sign in to comment.