Method: Broadside.load_config_file

Defined in:
lib/broadside.rb

.load_config_file(config_file) ⇒ Object

Raises:

  • (ArgumentError)


27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/broadside.rb', line 27

def self.load_config_file(config_file)
  raise ArgumentError, "#{config_file} does not exist" unless File.exist?(config_file)
  config.config_file = config_file

  begin
    if File.exist?(USER_CONFIG_FILE)
      debug "Loading user configuration from #{USER_CONFIG_FILE}"

      begin
        load(USER_CONFIG_FILE)
      rescue ConfigurationError
        # Suppress the exception because the system config file can be incomplete and validation failure is expected
      end
    end

    debug "Loading application configuration from #{config_file}"
    load(config_file)
  rescue LoadError
    error 'Encountered an error loading broadside configuration'
    raise
  end
end