diff --git a/spec/ameba/config_spec.cr b/spec/ameba/config_spec.cr index 6287de05..7b08f64c 100644 --- a/spec/ameba/config_spec.cr +++ b/spec/ameba/config_spec.cr @@ -85,7 +85,7 @@ module Ameba end it "raises when custom config file doesn't exist" do - expect_raises(Exception, "Config file is invalid: Unable to find config file foo.yml") do + expect_raises(Exception, "Config file is invalid: Config file does not exist foo.yml") do Config.load "foo.yml" end end diff --git a/src/ameba/config.cr b/src/ameba/config.cr index ad4f5dc6..2e5019de 100644 --- a/src/ameba/config.cr +++ b/src/ameba/config.cr @@ -120,7 +120,8 @@ class Ameba::Config protected def self.read_config(path = nil) if path - return File.exists?(path) ? File.read(path) : raise("Unable to find config file #{path}") + raise ArgumentError.new("Config file does not exist #{path}") unless File.exists?(path) + return File.read(path) end each_config_path do |config_path| return File.read(config_path) if File.exists?(config_path)