pry icon indicating copy to clipboard operation
pry copied to clipboard

Friendlier ArgumentError, better error output

Open kyrylo opened this issue 6 years ago • 4 comments

Pry should help users in entering correct input. There are many methods that help achieving that, which are too advanced for our current APIs, but there's one that would be trivial to implement right now.

Let's say, you don't remember how to instantiate Net::HTTP.new. You start with:

[14] pry(main)> Net::HTTP.new
ArgumentError: wrong number of arguments (given 0, expected 1..6)
from /Users/kyrylo/.rubies/ruby-2.4.2/lib/ruby/2.4.0/net/http.rb:634:in `new'

How would you know what arguments it expects?

[15] pry(main)> stat Net::HTTP.new
Method Information:
--
Name: new
Alias: None.
Owner: #<Class:Net::HTTP>
Visibility: public
Type: Bound
Arity: -2
Method Signature: new(address, port=?, p_addr=?, p_port=?, p_user=?, p_pass=?)
Source Location: /Users/kyrylo/.rubies/ruby-2.4.2/lib/ruby/2.4.0/net/http.rb:634

Method signature is useful here. But why would we type that manually? Proposed solution:

[14] pry(main)> Net::HTTP.new
ArgumentError: wrong number of arguments (given 0, expected 1..6)
Method Signature: new(address, port=?, p_addr=?, p_port=?, p_user=?, p_pass=?)
from /Users/kyrylo/.rubies/ruby-2.4.2/lib/ruby/2.4.0/net/http.rb:634:in `new'

kyrylo avatar May 26 '19 11:05 kyrylo

Hey I would love to work on this, is that okay? Would appreciate some pointers :)

edisonywh avatar Jun 11 '19 16:06 edisonywh

Sure, give it a try.

kyrylo avatar Jun 11 '19 18:06 kyrylo

Hey @kyrylo, I managed to take a look at it but I've been swarmed recently and don't think I could take this up in the near future, feel free to assign it to someone else, sorry!

edisonywh avatar Jun 22 '19 14:06 edisonywh

No worries and thanks for checking.

kyrylo avatar Jun 23 '19 02:06 kyrylo