From c4bca7cbb3eda883c7b09b6c0568a90fb8a85a5d Mon Sep 17 00:00:00 2001 From: dearblue Date: Sun, 28 Nov 2021 18:21:29 +0900 Subject: Align "wrong number of arguments" messages Make "N for M" into the form "given N, expected M". As I worked, I noticed that the `argnum_error()` function had a part to include the method name in the message. I think this part is no longer needed by https://github.com/mruby/mruby/pull/5394. - Before this patch ```console % bin/mruby -e '[1, 2, 3].each 0' trace (most recent call last): [1] -e:1 -e:1:in each: 'each': wrong number of arguments (1 for 0) (ArgumentError) ``` - After this patch ```console % bin/mruby -e '[1, 2, 3].each 0' trace (most recent call last): [1] -e:1 -e:1:in each: wrong number of arguments (given 1, expected 0) (ArgumentError) ``` --- mrbgems/mruby-string-ext/mrblib/string.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mrbgems/mruby-string-ext') diff --git a/mrbgems/mruby-string-ext/mrblib/string.rb b/mrbgems/mruby-string-ext/mrblib/string.rb index d485c51ef..d8fd120a0 100644 --- a/mrbgems/mruby-string-ext/mrblib/string.rb +++ b/mrbgems/mruby-string-ext/mrblib/string.rb @@ -151,7 +151,7 @@ class String # def slice!(arg1, arg2=nil) raise FrozenError, "can't modify frozen String" if frozen? - raise "wrong number of arguments (for 1..2)" if arg1.nil? && arg2.nil? + raise ArgumentError, "wrong number of arguments (expected 1..2)" if arg1.nil? && arg2.nil? if !arg1.nil? && !arg2.nil? idx = arg1 -- cgit v1.2.3