From 739a425d19aab349431bb47a7054c260967437af Mon Sep 17 00:00:00 2001 From: Dustin Cowles Date: Thu, 6 Jul 2023 11:15:36 -0500 Subject: [PATCH] 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 Tested-by: Service Cloud Jenkins QA-Review: Stephen Kacsmark Product-Review: Stephen Kacsmark --- gems/config_file/lib/config_file.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gems/config_file/lib/config_file.rb b/gems/config_file/lib/config_file.rb index ad8b331d0c7..4fee3638c03 100644 --- a/gems/config_file/lib/config_file.rb +++ b/gems/config_file/lib/config_file.rb @@ -46,7 +46,11 @@ module ConfigFile path = Rails.root.join("config/#{config_name}.yml") if path.file? 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) end if config