mardi 13 février 2018

Stop code execution if file is missing

I use this code in order to load configuration file. How I can stop code execution if line in file configuration is missing?

def load_environment_config(gateway, trx_type)
    @config = YAML.load_file("config/#{env}_config.yml")["#{env.upcase}"]
    puts "\nMissing gateway configuration for #{gateway} in file config/#{env}_config.yml!\n\n" unless @config[gateway]
  end

Aucun commentaire:

Enregistrer un commentaire