Skip to content

Commit 61425f2

Browse files
committed
Better Error handling when parsing database.yaml
Provides a better error message incase the database.yaml has some errors.
1 parent 03ef833 commit 61425f2

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

railties/lib/rails/application/configuration.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ def threadsafe!
105105
def database_configuration
106106
require 'erb'
107107
YAML.load ERB.new(IO.read(paths["config/database"].first)).result
108+
rescue Psych::SyntaxError => e
109+
raise "YAML syntax error occurred while parsing #{paths["config/database"].first}. " \
110+
"Please note that YAML must be consistently indented using spaces. Tabs are not allowed. " \
111+
"Error: #{e.message}"
108112
end
109113

110114
def log_level

0 commit comments

Comments
 (0)