Feature #5221

LoadEerror#path

Added by Koichi Sasada over 2 years ago. Updated about 2 years ago.

[ruby-core:39079]
Status:Closed
Priority:Normal
Assignee:Yukihiro Matsumoto
Category:core
Target version:2.0.0

Description

I read a part of activesupport and they add a method LoadError#path to return unloaded file name (*1).

*1: https://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/load_error.rb

How about to add this method on trunk?

This is a patch with some re-factoring around LoadError:
http://www.atdot.net/sp/view/y5xeql/readonly?lang=diff

noname (500 Bytes) Aaron Patterson, 08/26/2011 02:53 AM

loaderror.patch Magnifier (3.99 KB) Aaron Patterson, 02/25/2012 04:39 AM

History

#1 Updated by Eric Hodel over 2 years ago

RubyGems parses the exception message to determine the filename so having LoadError#path would make things easier.

Should we be able to raise a LoadError from ruby with #path set too?

Like:

raise LoadError.new("no such file -- #{path}", path)

#2 Updated by Aaron Patterson over 2 years ago

On Wed, Aug 24, 2011 at 12:28:50PM +0900, Koichi Sasada wrote:

Issue #5221 has been reported by Koichi Sasada.


Feature #5221: LoadEerror#path
http://redmine.ruby-lang.org/issues/5221

Author: Koichi Sasada
Status: Open
Priority: Normal
Assignee: Yukihiro Matsumoto
Category: core
Target version: 1.9.4

I read a part of activesupport and they add a method LoadError#path to return unloaded file name (*1).

*1: https://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/load_error.rb

How about to add this method on trunk?

This is a patch with some re-factoring around LoadError:
http://www.atdot.net/sp/view/y5xeql/readonly?lang=diff

Can we make it use a regular ivar for path rather than an ivar with no
"@"? Using private ivars like this makes life hard for doing
introspection (like the introspection required for YAML to dump / load).

Like this: https://gist.github.com/1171267

--
Aaron Patterson
http://tenderlovemaking.com/

#3 Updated by Aaron Patterson about 2 years ago

Bump. Any news on this?

#4 Updated by Aaron Patterson about 2 years ago

I've updated the patch to include a test:

https://gist.github.com/1855072

#5 Updated by Aaron Patterson about 2 years ago

  • Target version changed from 1.9.4 to 2.0.0

#6 Updated by Aaron Patterson about 2 years ago

I've reduced the diff slightly. May I commit this?

#7 Updated by Koichi Sasada about 2 years ago

(2011/08/26 2:45), Aaron Patterson wrote:

Can we make it use a regular ivar for path rather than an ivar with no
"@"? Using private ivars like this makes life hard for doing
introspection (like the introspection required for YAML to dump / load).

I don't have any objection. Matz, what do you think about it?

--
// SASADA Koichi at atdot dot net

#8 Updated by Yukihiro Matsumoto about 2 years ago

I agree.

#9 Updated by Aaron Patterson about 2 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

Applied in r34938

Also available in: Atom PDF