Module: Bang::ExceptionExtension
- Included in:
- Exception
- Defined in:
- lib/bang.rb
Overview
Class-level extension for Exception class that adds ‘#raised?` and `#rescued?`.
Instance Method Summary collapse
-
#raised? ⇒ true, false
Yield a given block and return ‘true` if this exception specifically is raised, otherwise `false`.
-
#rescued? ⇒ true, false
Yield a given block and return ‘true` if this exception, or a sub-class there-of is raised, otherwise `false`.
Instance Method Details
#raised? ⇒ true, false
Yield a given block and return ‘true` if this exception specifically is raised, otherwise `false`.
319 320 321 322 323 324 325 326 327 328 |
# File 'lib/bang.rb', line 319 def raised? #:yield: begin yield false rescue self => err self == err.class rescue Exception false end end |
#rescued? ⇒ true, false
Yield a given block and return ‘true` if this exception, or a sub-class there-of is raised, otherwise `false`.
336 337 338 339 340 341 342 343 344 345 |
# File 'lib/bang.rb', line 336 def rescued? #:yield: begin yield false rescue self true rescue Exception false end end |