output config name when encountering a parser error

This will help people quickly identify a syntax error in a config file
such as dynamic_settings.yml in their development environment.

flag=none

Test plan:
- Specs Pass

Change-Id: Icd4597424da4c3a44570c0de1258edc52bce378c
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/322203
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Stephen Kacsmark <skacsmark@instructure.com>
Product-Review: Stephen Kacsmark <skacsmark@instructure.com>
This commit is contained in:
Dustin Cowles 2023-07-06 11:15:36 -05:00
parent e43ddc2287
commit 739a425d19
1 changed files with 5 additions and 1 deletions

View File

@ -46,7 +46,11 @@ module ConfigFile
path = Rails.root.join("config/#{config_name}.yml") path = Rails.root.join("config/#{config_name}.yml")
if path.file? if path.file?
config_string = ERB.new(path.read) config_string = ERB.new(path.read)
config = YAML.safe_load(config_string.result, aliases: true) begin
config = YAML.safe_load(config_string.result, aliases: true)
rescue Psych::SyntaxError => e
raise e, "Error parsing #{path} #{e.message}"
end
config = config.with_indifferent_access if config.respond_to?(:with_indifferent_access) config = config.with_indifferent_access if config.respond_to?(:with_indifferent_access)
end end
if config if config