Feature #8062

Argument error stack trace to specify the 'called' method

Added by Benjamin Sinclaire about 1 year ago. Updated 11 months ago.

[ruby-core:53272]
Status:Feedback
Priority:Normal
Assignee:-
Category:-
Target version:next minor

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/actionview/helpers/formhelper.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/actionview/helpers/formhelper.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

History

#1 Updated by Benjamin Sinclaire about 1 year ago

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

#2 Updated by Zachary Scott 11 months ago

  • Status changed from Open to Feedback
  • Target version set to next minor

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

Also available in: Atom PDF