From 61425f2c6d14fe7151b09ffe5a5353924582e5b0 Mon Sep 17 00:00:00 2001 From: Gaurish Sharma Date: Tue, 20 Nov 2012 16:18:28 +0530 Subject: [PATCH] Better Error handling when parsing database.yaml Provides a better error message incase the database.yaml has some errors. --- railties/lib/rails/application/configuration.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb index f97e66985c..89afeaeec5 100644 --- a/railties/lib/rails/application/configuration.rb +++ b/railties/lib/rails/application/configuration.rb @@ -105,6 +105,10 @@ module Rails def database_configuration require 'erb' YAML.load ERB.new(IO.read(paths["config/database"].first)).result + rescue Psych::SyntaxError => e + raise "YAML syntax error occurred while parsing #{paths["config/database"].first}. " \ + "Please note that YAML must be consistently indented using spaces. Tabs are not allowed. " \ + "Error: #{e.message}" end def log_level