From 660dcd5b7c038f86002ddecf3562e1b7018e143c Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Sat, 12 Jan 2019 15:18:22 -0800 Subject: Fix Bitbucket Server importer error handling The importer would display a 500 error page if you attempted to import using a non-existent DNS entry. This commit rescues known network issues and consolidates them into BitbucketServer::Connection::ConnectionError`. The previous error handling in the paginator doesn't work because it returns a lazy collection. Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/56154 --- app/controllers/import/bitbucket_server_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/controllers/import/bitbucket_server_controller.rb') diff --git a/app/controllers/import/bitbucket_server_controller.rb b/app/controllers/import/bitbucket_server_controller.rb index 575c40d5f6f..87338488eba 100644 --- a/app/controllers/import/bitbucket_server_controller.rb +++ b/app/controllers/import/bitbucket_server_controller.rb @@ -40,7 +40,7 @@ class Import::BitbucketServerController < Import::BaseController else render json: { errors: 'This namespace has already been taken! Please choose another one.' }, status: :unprocessable_entity end - rescue BitbucketServer::Client::ServerError => e + rescue BitbucketServer::Connection::ConnectionError => e render json: { errors: "Unable to connect to server: #{e}" }, status: :unprocessable_entity end @@ -62,7 +62,7 @@ class Import::BitbucketServerController < Import::BaseController already_added_projects_names = @already_added_projects.pluck(:import_source) @repos.reject! { |repo| already_added_projects_names.include?(repo.browse_url) } - rescue BitbucketServer::Connection::ConnectionError, BitbucketServer::Client::ServerError => e + rescue BitbucketServer::Connection::ConnectionError => e flash[:alert] = "Unable to connect to server: #{e}" clear_session_data redirect_to new_import_bitbucket_server_path -- cgit v1.2.1