Project

General

Profile

Feature #10881

NoMethodError#receiever

Added by yuki24 (Yuki Nishijima) over 3 years ago. Updated about 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:68215]

Description

I would like NoMethodError to have receiver method:

receiver    = "receiver"
exception = receiver.doesnt_exist rescue $!

exception.receiver == receiver # => true

This helps did_you_mean gem implement its features without having native C exceptions, and also makes it easier to add "did you mean?" feature to irb. Let mw know what you think. Thanks!

Associated revisions

Revision 51de63df
Added by nobu (Nobuyoshi Nakada) about 3 years ago

error.c: NameError#receiver

  • error.c (name_err_receiver): add NameError#receiver method. [Feature #10881]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50945 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 50945
Added by nobu (Nobuyoshi Nakada) about 3 years ago

error.c: NameError#receiver

  • error.c (name_err_receiver): add NameError#receiver method. [Feature #10881]

Revision 50945
Added by nobu (Nobuyoshi Nakada) about 3 years ago

error.c: NameError#receiver

  • error.c (name_err_receiver): add NameError#receiver method. [Feature #10881]

Revision 50945
Added by nobu (Nobuyoshi Nakada) about 3 years ago

error.c: NameError#receiver

  • error.c (name_err_receiver): add NameError#receiver method. [Feature #10881]

Revision 50945
Added by nobu (Nobuyoshi Nakada) about 3 years ago

error.c: NameError#receiver

  • error.c (name_err_receiver): add NameError#receiver method. [Feature #10881]

Revision fac04ba9
Added by nobu (Nobuyoshi Nakada) about 3 years ago

NEWS: NameError#receiver [Feature #10881]

[ci skip]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50946 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 50946
Added by nobu (Nobuyoshi Nakada) about 3 years ago

NEWS: NameError#receiver [Feature #10881]

[ci skip]

Revision 50946
Added by nobu (Nobuyoshi Nakada) about 3 years ago

NEWS: NameError#receiver [Feature #10881]

[ci skip]

Revision 50946
Added by nobu (Nobuyoshi Nakada) about 3 years ago

NEWS: NameError#receiver [Feature #10881]

[ci skip]

Revision 50946
Added by nobu (Nobuyoshi Nakada) about 3 years ago

NEWS: NameError#receiver [Feature #10881]

[ci skip]

Revision c23a7b0d
Added by nobu (Nobuyoshi Nakada) about 3 years ago

error.c: ArgumentError if no receiver

  • error.c (name_err_receiver): raise ArgumentError if no receiver is available on this exception object. [Feature #10881]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51002 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 51002
Added by nobu (Nobuyoshi Nakada) about 3 years ago

error.c: ArgumentError if no receiver

  • error.c (name_err_receiver): raise ArgumentError if no receiver is available on this exception object. [Feature #10881]

Revision 51002
Added by nobu (Nobuyoshi Nakada) about 3 years ago

error.c: ArgumentError if no receiver

  • error.c (name_err_receiver): raise ArgumentError if no receiver is available on this exception object. [Feature #10881]

Revision 51002
Added by nobu (Nobuyoshi Nakada) about 3 years ago

error.c: ArgumentError if no receiver

  • error.c (name_err_receiver): raise ArgumentError if no receiver is available on this exception object. [Feature #10881]

Revision 51002
Added by nobu (Nobuyoshi Nakada) about 3 years ago

error.c: ArgumentError if no receiver

  • error.c (name_err_receiver): raise ArgumentError if no receiver is available on this exception object. [Feature #10881]

Revision 7a929727
Added by nobu (Nobuyoshi Nakada) almost 3 years ago

error.c: rb_name_err_new

  • error.c (rb_name_err_new): new function to create NameError exception instance. [Feature #10881]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52320 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 52320
Added by nobu (Nobuyoshi Nakada) almost 3 years ago

error.c: rb_name_err_new

  • error.c (rb_name_err_new): new function to create NameError exception instance. [Feature #10881]

Revision 52320
Added by nobu (Nobuyoshi Nakada) almost 3 years ago

error.c: rb_name_err_new

  • error.c (rb_name_err_new): new function to create NameError exception instance. [Feature #10881]

Revision 52320
Added by nobu (Nobuyoshi Nakada) almost 3 years ago

error.c: rb_name_err_new

  • error.c (rb_name_err_new): new function to create NameError exception instance. [Feature #10881]

Revision 52320
Added by nobu (Nobuyoshi Nakada) almost 3 years ago

error.c: rb_name_err_new

  • error.c (rb_name_err_new): new function to create NameError exception instance. [Feature #10881]

Revision 72ff61f4
Added by nobu (Nobuyoshi Nakada) almost 3 years ago

NameError#receiver of uninitialized constant

  • error.c (name_err_mesg_to_str): quote the name if unprintable.
  • object.c (check_setter_id): use rb_check_id to convert names.
  • variable.c (uninitialized_constant): use NameError::message to keep the receiver of uninitialized constant. [Feature #10881]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52321 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 52321
Added by nobu (Nobuyoshi Nakada) almost 3 years ago

NameError#receiver of uninitialized constant

  • error.c (name_err_mesg_to_str): quote the name if unprintable.
  • object.c (check_setter_id): use rb_check_id to convert names.
  • variable.c (uninitialized_constant): use NameError::message to keep the receiver of uninitialized constant. [Feature #10881]

Revision 52321
Added by nobu (Nobuyoshi Nakada) almost 3 years ago

NameError#receiver of uninitialized constant

  • error.c (name_err_mesg_to_str): quote the name if unprintable.
  • object.c (check_setter_id): use rb_check_id to convert names.
  • variable.c (uninitialized_constant): use NameError::message to keep the receiver of uninitialized constant. [Feature #10881]

Revision 52321
Added by nobu (Nobuyoshi Nakada) almost 3 years ago

NameError#receiver of uninitialized constant

  • error.c (name_err_mesg_to_str): quote the name if unprintable.
  • object.c (check_setter_id): use rb_check_id to convert names.
  • variable.c (uninitialized_constant): use NameError::message to keep the receiver of uninitialized constant. [Feature #10881]

Revision 52321
Added by nobu (Nobuyoshi Nakada) almost 3 years ago

NameError#receiver of uninitialized constant

  • error.c (name_err_mesg_to_str): quote the name if unprintable.
  • object.c (check_setter_id): use rb_check_id to convert names.
  • variable.c (uninitialized_constant): use NameError::message to keep the receiver of uninitialized constant. [Feature #10881]

Revision a4f838c7
Added by nobu (Nobuyoshi Nakada) almost 3 years ago

error.c: receiver in NameError

  • error.c (rb_name_err_new): store the receiver directly.
  • error.c (name_err_receiver): return directly stored receiver. [Feature #10881]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 52322
Added by nobu (Nobuyoshi Nakada) almost 3 years ago

error.c: receiver in NameError

  • error.c (rb_name_err_new): store the receiver directly.
  • error.c (name_err_receiver): return directly stored receiver. [Feature #10881]

Revision 52322
Added by nobu (Nobuyoshi Nakada) almost 3 years ago

error.c: receiver in NameError

  • error.c (rb_name_err_new): store the receiver directly.
  • error.c (name_err_receiver): return directly stored receiver. [Feature #10881]

Revision 52322
Added by nobu (Nobuyoshi Nakada) almost 3 years ago

error.c: receiver in NameError

  • error.c (rb_name_err_new): store the receiver directly.
  • error.c (name_err_receiver): return directly stored receiver. [Feature #10881]

Revision 52322
Added by nobu (Nobuyoshi Nakada) almost 3 years ago

error.c: receiver in NameError

  • error.c (rb_name_err_new): store the receiver directly.
  • error.c (name_err_receiver): return directly stored receiver. [Feature #10881]

Revision a2369fc2
Added by nobu (Nobuyoshi Nakada) almost 3 years ago

encoding for inspect

  • test/ruby/test_{exception,module,object}.rb: inspect result depend on the default external encoding. [Feature #10881]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52323 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 52323
Added by nobu (Nobuyoshi Nakada) almost 3 years ago

encoding for inspect

  • test/ruby/test_{exception,module,object}.rb: inspect result depend on the default external encoding. [Feature #10881]

Revision 52323
Added by nobu (Nobuyoshi Nakada) almost 3 years ago

encoding for inspect

  • test/ruby/test_{exception,module,object}.rb: inspect result depend on the default external encoding. [Feature #10881]

Revision 52323
Added by nobu (Nobuyoshi Nakada) almost 3 years ago

encoding for inspect

  • test/ruby/test_{exception,module,object}.rb: inspect result depend on the default external encoding. [Feature #10881]

Revision 52323
Added by nobu (Nobuyoshi Nakada) almost 3 years ago

encoding for inspect

  • test/ruby/test_{exception,module,object}.rb: inspect result depend on the default external encoding. [Feature #10881]

History

#1 [ruby-core:69632] Updated by matz (Yukihiro Matsumoto) about 3 years ago

Looks OK for me. I am interested in how JRuby/Rubinius guys feel about the proposal.

Matz.

#2 [ruby-core:69641] Updated by yuki24 (Yuki Nishijima) about 3 years ago

Thanks Matsumoto-san.

I realized that the last line in the example above is wrong, it has to use #equal? instead of #==:

exception.receiver.equal?(receiver) # => true

#3 Updated by nobu (Nobuyoshi Nakada) about 3 years ago

  • Status changed from Open to Closed

Applied in changeset r50945.


error.c: NameError#receiver

  • error.c (name_err_receiver): add NameError#receiver method. [Feature #10881]

Also available in: Atom PDF