Determine whether to return the error line or error messages by the value of eturn_error_line
Signed-off-by: Lin Jiaxin ljx.joe@qq.com --- lib/error_messages.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/lib/error_messages.rb b/lib/error_messages.rb index 3e1564b..81e0034 100644 --- a/lib/error_messages.rb +++ b/lib/error_messages.rb @@ -40,12 +40,16 @@ 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 + if return_error_line + error_messages_by_error_id << k + else + error_messages_by_error_id += v.to_a + end end end error_messages_by_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
if return_error_line
error_messages_by_error_id << k
else
error_messages_by_error_id += v.to_a
end
above if-else => error_messages_by_error_id += return_error_line ? [k] : v.to_a
Thanks, Luan Shengde
end end error_messages_by_error_id
-- 2.23.0