Determine whether to return the error line or error messages by the value of return_error_line
Signed-off-by: Lin Jiaxin ljx.joe@qq.com --- lib/error_messages.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/error_messages.rb b/lib/error_messages.rb index 3e1564b..d83d890 100644 --- a/lib/error_messages.rb +++ b/lib/error_messages.rb @@ -40,12 +40,12 @@ class ErrorMessages return @error_messages end
- def obtain_error_messages_by_error_id(error_id) + def obtain_error_messages_by_error_id(error_id, return_error_line = false) error_messages_by_error_id = [] error_messages = obtain_error_messages error_messages.each do |k, v| if ('build-pkg.' + build_pkg_error_id(k)) == error_id - error_messages_by_error_id += v.to_a + error_messages_by_error_id += return_error_line ? [k] : v.to_a end end error_messages_by_error_id
- def obtain_error_messages_by_error_id(error_id)
- def obtain_error_messages_by_error_id(error_id, return_error_line = false) error_messages_by_error_id = [] error_messages = obtain_error_messages error_messages.each do |k, v| if ('build-pkg.' + build_pkg_error_id(k)) == error_id
line above avoid use '+' to build a string unless line by line you can use join or "str#{var}str" to build it
Thanks, Luan Shengde
error_messages_by_error_id += v.to_a
end error_messages_by_error_iderror_messages_by_error_id += return_error_line ? [k] : v.to_a end
-- 2.23.0