ÿØÿà JFIF    ÿÛ „  ( %!1!%)+//.383,7(-.+  -%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ  ¥2" ÿÄ     ÿÄ J    ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ   ÿÄ *  !1AQa‘"2q3±ð#b¡ÿÚ   ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú "SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁT­ÃÛ5 ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßw­pŽF|È¥ù®häðÍѶ¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e ríV ?> ......................................... ............................................................................. ÿØÿà JFIF    ÿÛ „  ( %!1!%)+//.383,7(-.+  -%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ  ¥2" ÿÄ     ÿÄ J    ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ   ÿÄ *  !1AQa‘"2q3±ð#b¡ÿÚ   ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú "SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁT­ÃÛ5 ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßw­pŽF|È¥ù®häðÍѶ¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e ríV ?> ......................................... ............................................................................. ???????????????????????????????????? ???????????????????????????????????? ÿØÿà JFIF    ÿÛ „  ( %!1!%)+//.383,7(-.+  -%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ  ¥2" ÿÄ     ÿÄ J    ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ   ÿÄ *  !1AQa‘"2q3±ð#b¡ÿÚ   ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú "SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁT­ÃÛ5 ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßw­pŽF|È¥ù®häðÍѶ¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e ríV ?> ......................................... ............................................................................. ÿØÿà JFIF    ÿÛ „  ( %!1!%)+//.383,7(-.+  -%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ  ¥2" ÿÄ     ÿÄ J    ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ   ÿÄ *  !1AQa‘"2q3±ð#b¡ÿÚ   ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú "SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁT­ÃÛ5 ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßw­pŽF|È¥ù®häðÍѶ¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e ríV ?> ......................................... ............................................................................. ???????????????????????????????????? ???????????????????????????????????? U:RDoc::TopLevel[ iI"syntax/exceptions.rdoc:ETcRDoc::Parser::Simpleo:RDoc::Markup::Document: @parts[)S:RDoc::Markup::Heading: leveli: textI"Exception Handling;To:RDoc::Markup::BlankLineo:RDoc::Markup::Paragraph;[I"5Exceptions are rescued in a +begin+/+end+ block:;T@ o:RDoc::Markup::Verbatim;[ I" begin ;TI" # code that might raise ;TI" rescue ;TI" # handle exception ;TI" end ;T: @format0o; ;[I"TIf you are inside a method, you do not need to use +begin+ or +end+ unless you ;TI"3wish to limit the scope of rescued exceptions:;T@ o;;[ I"def my_method ;TI" # ... ;TI" rescue ;TI" # ... ;TI" end ;T;0o; ;[I";The same is true for a +class+, +module+, and +block+:;T@ o;;[ I"[0, 1, 2].map do |i| ;TI" 10 / i ;TI"rescue ZeroDivisionError ;TI" nil ;TI" end ;TI"#=> [nil, 10, 5] ;T;0o; ;[I"FYou can assign the exception to a local variable by using => ;TI"8variable_name at the end of the +rescue+ line:;T@ o;;[ I" begin ;TI" # ... ;TI"rescue => exception ;TI" warn exception.message ;TI". raise # re-raise the current exception ;TI" end ;T;0o; ;[I"QBy default, StandardError and its subclasses are rescued. You can rescue a ;TI"Tspecific set of exception classes (and their subclasses) by listing them after ;TI"+rescue+:;T@ o;;[ I" begin ;TI" # ... ;TI"%rescue ArgumentError, NameError ;TI"+ # handle ArgumentError or NameError ;TI" end ;T;0o; ;[I"DYou may rescue different types of exceptions in different ways:;T@ o;;[I" begin ;TI" # ... ;TI"rescue ArgumentError ;TI" # handle ArgumentError ;TI"rescue NameError ;TI" # handle NameError ;TI" rescue ;TI"" # handle any StandardError ;TI" end ;T;0o; ;[I"UThe exception is matched to the rescue section starting at the top, and matches ;TI"Tonly once. If an ArgumentError is raised in the begin section, it will not be ;TI"*handled in the StandardError section.;T@ o; ;[I"&You may retry rescued exceptions:;T@ o;;[ I" begin ;TI" # ... ;TI" rescue ;TI"D # do something that may change the result of the begin block ;TI" retry ;TI" end ;T;0o; ;[I"QExecution will resume at the start of the begin block, so be careful not to ;TI"create an infinite loop.;T@ o; ;[ I"RInside a rescue block is the only valid location for +retry+, all other uses ;TI"Swill raise a SyntaxError. If you wish to retry a block iteration use +redo+. ;TI"MSee {Control Expressions}[rdoc-ref:syntax/control_expressions.rdoc] for ;TI" details.;T@ o; ;[I"RTo always run some code whether an exception was raised or not, use +ensure+:;T@ o;;[ I" begin ;TI" # ... ;TI" rescue ;TI" # ... ;TI" ensure ;TI"W # this always runs BUT does not implicitly return the last evaluated statement. ;TI" end ;T;0o; ;[I"@You may also run some code when an exception is not raised:;T@ o;;[I" begin ;TI" # ... ;TI" rescue ;TI" # ... ;TI" else ;TI"] # this runs only when no exception was raised AND return the last evaluated statement ;TI" ensure ;TI" # this always runs. ;TI"Z # It is evaluated after the evaluation of either the `rescue` or the `else` block. ;TI"( # It will not return implicitly. ;TI" end ;T;0o; ;[I"NB : Without explicit +return+ in the +ensure+ block, +begin+/+end+ block will return the last evaluated statement before entering in the `ensure` block.;T: @file@:0@omit_headings_from_table_of_contents_below0