summaryrefslogtreecommitdiffhomepage
path: root/ruby.html.markdown
diff options
context:
space:
mode:
authorGeoff Liu <cangming.liu@gmail.com>2014-11-11 17:42:28 -0800
committerGeoff Liu <cangming.liu@gmail.com>2014-11-11 18:06:19 -0800
commit9d8d8710053a73e5099483f9e07c9d789cec73e5 (patch)
tree7da03b2bef2c7fa5e9a8ea0ddc4acf919bce980f /ruby.html.markdown
parente784f52d33475b0cba059a0c07ad01b0e63578a9 (diff)
parentad951f2615175b917b7410e667ef91d119468c5a (diff)
Merge
Diffstat (limited to 'ruby.html.markdown')
-rw-r--r--ruby.html.markdown14
1 files changed, 14 insertions, 0 deletions
diff --git a/ruby.html.markdown b/ruby.html.markdown
index 3c67de2e..e58c513d 100644
--- a/ruby.html.markdown
+++ b/ruby.html.markdown
@@ -10,6 +10,7 @@ contributors:
- ["Marcos Brizeno", "http://www.about.me/marcosbrizeno"]
- ["Ariel Krakowski", "http://www.learneroo.com"]
- ["Dzianis Dashkevich", "https://github.com/dskecse"]
+ - ["Levi Bostian", "https://github.com/levibostian"]
---
@@ -271,6 +272,19 @@ else
end
#=> "OK job"
+# exception handling:
+begin
+ # code here that might raise an exception
+ raise NoMemoryError, 'You ran out of memory.'
+rescue NoMemoryError => exception_variable
+ puts 'NoMemoryError was raised', exception_variable
+rescue RuntimeError => other_exception_variable
+ puts 'RuntimeError was raised now'
+else
+ puts 'This runs if no exceptions were thrown at all'
+ensure
+ puts 'This code always runs no matter what'
+end
# Functions