From 5b8f8d2bdc9f69aa4e28375b8a79ab9671ed6a1c Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Tue, 23 May 2017 15:15:51 +1000 Subject: Rescue test settings for chat notification services Return error message to show user when testing chat notification services. --- app/models/project_services/chat_notification_service.rb | 7 +++++++ changelogs/unreleased/mrchrisw-handle-chat-error.yml | 4 ++++ 2 files changed, 11 insertions(+) create mode 100644 changelogs/unreleased/mrchrisw-handle-chat-error.yml diff --git a/app/models/project_services/chat_notification_service.rb b/app/models/project_services/chat_notification_service.rb index 779ef54cfcb..41fbd8c8c1c 100644 --- a/app/models/project_services/chat_notification_service.rb +++ b/app/models/project_services/chat_notification_service.rb @@ -86,6 +86,13 @@ class ChatNotificationService < Service raise NotImplementedError end + def test(data) + result = execute(data) + { success: true, result: result } + rescue HTTParty::Error, Timeout::Error, SocketError, Errno::ECONNRESET, Errno::ECONNREFUSED, OpenSSL::SSL::SSLError => error + { success: false, result: error.message } + end + private def notify(message, opts) diff --git a/changelogs/unreleased/mrchrisw-handle-chat-error.yml b/changelogs/unreleased/mrchrisw-handle-chat-error.yml new file mode 100644 index 00000000000..7ac6d6fee23 --- /dev/null +++ b/changelogs/unreleased/mrchrisw-handle-chat-error.yml @@ -0,0 +1,4 @@ +--- +title: Rescue test settings for chat notification services +merge_request: +author: -- cgit v1.2.3