Commit 45197636ba28292e680bd3397fb4d182f6bca688
Exists in
master
Merge pull request #14 from fallwith/master
initialization: better error handling for a YAML file that is missing the required namespace section
Showing
1 changed file
with
3 additions
and
1 deletions
Show diff stats
lib/settingslogic.rb
... | ... | @@ -103,7 +103,9 @@ class Settingslogic < Hash |
103 | 103 | self.replace hash_or_file |
104 | 104 | else |
105 | 105 | hash = YAML.load(ERB.new(File.read(hash_or_file)).result).to_hash |
106 | - hash = hash[self.class.namespace] if self.class.namespace | |
106 | + if self.class.namespace | |
107 | + hash = hash[self.class.namespace] or raise MissingSetting, "Missing setting '#{self.class.namespace}' in #{hash_or_file}" | |
108 | + end | |
107 | 109 | self.replace hash |
108 | 110 | end |
109 | 111 | @section = section || self.class.source # so end of error says "in application.yml" | ... | ... |