Commit 09c38e46 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Only pass item name

parent 94178149
...@@ -42,9 +42,12 @@ module Gitlab ...@@ -42,9 +42,12 @@ module Gitlab
end.join end.join
end end
def verify_record!(record, exception, error_title) def verify_record!(record, exception, name)
return if record.persisted? return if record.persisted?
error_title =
"The #{name} could not be created for the following reasons:"
msg = error_title + record.errors.full_messages.map do |error| msg = error_title + record.errors.full_messages.map do |error|
"\n\n- #{error}" "\n\n- #{error}"
end.join end.join
......
...@@ -22,11 +22,7 @@ module Gitlab ...@@ -22,11 +22,7 @@ module Gitlab
validate_permission!(:create_issue) validate_permission!(:create_issue)
verify_record!( verify_record!(create_issue, InvalidIssueError, 'issue')
create_issue,
InvalidIssueError,
"The issue could not be created for the following reasons:"
)
end end
def author def author
......
...@@ -19,11 +19,7 @@ module Gitlab ...@@ -19,11 +19,7 @@ module Gitlab
raise NoteableNotFoundError unless sent_notification.noteable raise NoteableNotFoundError unless sent_notification.noteable
raise EmptyEmailError if message.blank? raise EmptyEmailError if message.blank?
verify_record!( verify_record!(create_note, InvalidNoteError, 'comment')
create_note,
InvalidNoteError,
"The comment could not be created for the following reasons:"
)
end end
def author def author
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment