Skip to content

Commit

Permalink
Remove newlines from error message
Browse files Browse the repository at this point in the history
Newlines can cause trouble with translations as well as presentation in
the UI. This particular string doesn't actually need the newline as part
of the translation string, so this commit changes it to just not have it.

Alternative to #23213
  • Loading branch information
Fryguy committed Sep 30, 2024
1 parent 1bd9520 commit 8d24399
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
6 changes: 1 addition & 5 deletions app/models/miq_provision_virt_workflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -772,11 +772,7 @@ def self.from_ws_ver_1_0(version, user, src_name, target_name, auto_approve, tag
values[:vm_tags] = p.ws_tags(tags, :parse_ws_string_v1)
values[:ws_values] = p.ws_values(additional_values, :parse_ws_string_v1)

if p.validate(values) == false
errors = []
p.fields { |_fn, f, _dn, _d| errors << f[:error] unless f[:error].nil? }
raise _("Provision failed for the following reasons:\n%{errors}") % {:errors => errors.join("\n")}
end
p.raise_validate_errors if p.validate(values) == false

p.make_request(nil, values, nil, auto_approve)
end
Expand Down
6 changes: 3 additions & 3 deletions app/models/miq_request_workflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1507,9 +1507,9 @@ def ws_schedule_fields(values, _fields, data)
def raise_validate_errors
errors = []
fields { |_fn, f, _dn, _d| errors << f[:error] unless f[:error].nil? }
err_text = "Provision failed for the following reasons:\n#{errors.join("\n")}"
_log.error("<#{err_text}>")
raise _("Provision failed for the following reasons:\n%{errors}") % {:errors => errors.join("\n")}
err_text = errors.join("\n").insert(0, "\n")
_log.error("<Provision failed for the following reasons:#{err_text}>")
raise _("Provision failed for the following reasons:%{errors}") % {:errors => err_text}
end

private
Expand Down

0 comments on commit 8d24399

Please sign in to comment.