Only pass item name

This commit is contained in:
Lin Jen-Shin 2016-06-15 20:10:16 +08:00
parent 9417814970
commit 09c38e46e5
3 changed files with 6 additions and 11 deletions

View File

@ -42,9 +42,12 @@ module Gitlab
end.join
end
def verify_record!(record, exception, error_title)
def verify_record!(record, exception, name)
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|
"\n\n- #{error}"
end.join

View File

@ -22,11 +22,7 @@ module Gitlab
validate_permission!(:create_issue)
verify_record!(
create_issue,
InvalidIssueError,
"The issue could not be created for the following reasons:"
)
verify_record!(create_issue, InvalidIssueError, 'issue')
end
def author

View File

@ -19,11 +19,7 @@ module Gitlab
raise NoteableNotFoundError unless sent_notification.noteable
raise EmptyEmailError if message.blank?
verify_record!(
create_note,
InvalidNoteError,
"The comment could not be created for the following reasons:"
)
verify_record!(create_note, InvalidNoteError, 'comment')
end
def author