Project

General

Profile

Actions

Feature #8062

closed

Argument error stack trace to specify the 'called' method

Added by randoum (Benj Benj) about 11 years ago. Updated about 6 years ago.

Status:
Feedback
Assignee:
-
Target version:
-
[ruby-core:53272]

Description

Note
Feature request about the stack trace generated by Ruby, the step by step bellow is using Rails, but if I'm not wrong this is Ruby related.

Request
When an ArgumentError exception is raised, the stack trace should display the 'called' method, it actually display only the 'caller' method. This would be great help for debugging

Background for the step by step
Rails define a method named 'fields_for' in module ActionView::Helpers::FormHelper, I'll be writing my step by step depending on that but it should be possible to reproduce in any similar situation

Step by step
1- Create a module called 'MyModule' and create a method called 'fields_for'

2- In an view, write do code with the following statement 'form_for @mymodel { |f| f.submit }'

3- Execute the code, and see that the top line of the stack trace after the exception is raised is:
(gem) actionpack-3.2.12/lib/action_view/helpers/form_helper.rb:378:in `form_for'

This is actually the line in Rails module that perform the call to the method 'fields_for'
But there is no way to understand that Ruby trying to call the method from my module instead of the method from Rails module
A good solution would be to display the name and position of the 'called' method in the stack trace, so the last line of the stack trace would clearly indicate that we have a naming conflict

ruby-v: (gem) actionpack-3.2.12/lib/action_view/helpers/form_helper.rb:378:in `form_for'

Sorry if it looks confuse, I can't find a better way to explain it, I hope you guys got the picture

Many thanks for your time

Updated by randoum (Benj Benj) about 11 years ago

(sorry I just realized my CTRL+C bug sometimes)
ruby -v: ruby 1.9.3p327 (2012-11-10 revision 37606) [i686-linux]

Updated by zzak (zzak _) almost 11 years ago

  • Status changed from Open to Feedback
  • Target version set to 2.6

Can you provide a plain ruby example? And include the output you'd expect?

Actions #3

Updated by naruse (Yui NARUSE) about 6 years ago

  • Target version deleted (2.6)
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0