Skip to content

Instantly share code, notes, and snippets.

@adis-io
Last active October 10, 2016 14:16
Show Gist options
  • Save adis-io/7b09ca0387d78f3cee31cd65a1e5c51f to your computer and use it in GitHub Desktop.
Save adis-io/7b09ca0387d78f3cee31cd65a1e5c51f to your computer and use it in GitHub Desktop.
Re raise exception with custom message
env = ENV.fetch('APP_ENV', 'development')
begin
storage_config = YAML.load_file("#{Rails.root.to_s}/config/storage.yml")[env]
rescue Errno::ENOENT
message = ".config/storage.yml not found! Perhaps you forgot to copy it from storage.yml.example? (#{$!})"
raise $!, message, $!.backtrace
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment