Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove newlines from error message #23215

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note, the newline might cause issues if translators don't embed it in their translations.

See: #23218 (comment)

_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