Skip to content

Commit

Permalink
Merge pull request #23215 from Fryguy/better_error_messages
Browse files Browse the repository at this point in the history
Remove newlines from error message
  • Loading branch information
jrafanie authored Oct 1, 2024
2 parents 5259837 + 8d24399 commit 2c6cd3c
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 2c6cd3c

Please sign in to comment.