Project

General

Profile

Actions

Bug #6202

closed

The 'rescue' modifier can not be used in 'require'

Added by yimutang (Joey Zhou) about 12 years ago. Updated about 12 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.3p125 (2012-02-16) [i386-mingw32]
Backport:
[ruby-core:43676]

Description

My Ruby version is: ruby 1.9.3p125 (2012-02-16) [i386-mingw32]

I found that the 'rescue' modifier can not be used in 'require', for example:

require 'not_exist' rescue require 'set' # this will raise a LoadError

I must write a begin/rescue block to do this:

begin
require 'not_exist'
rescue LoadError
require 'set' # this is ok
end

I don't know if it is a bug, I think a one-line require/rescue may be good idiom.

Updated by nobu (Nobuyoshi Nakada) about 12 years ago

  • Status changed from Open to Rejected

'rescue' modifier and 'rescue' clause with no exception classes catch only StandardError and its subclasses.
LoadError can't be caught.

Actions

Also available in: Atom PDF

Like0
Like0