Skip to content

Instantly share code, notes, and snippets.

@tigawa
Last active December 11, 2015 19:08
Show Gist options
  • Save tigawa/4645982 to your computer and use it in GitHub Desktop.
Save tigawa/4645982 to your computer and use it in GitHub Desktop.
ruby 例外処理
begin
content = load_blog_data(file_name)
rescue BlogDataNotFound
STDERR.puts "ファイル#(file_name}がみつかりません"
rescue BlogDataFormatError
STDERR.puts "#{file_name}内のブログデータが壊れています"
rescue Exception => exc
STDERR.puts "#{file_name} ロード時の一般エラー:#{exc.message}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment