OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
[#47207] extract error handling
Eric Schuberta2cc8123a674
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/download_link_query.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/download_link_query.rbindex 51b2d10a416..896a0ecdf0f 100644--- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/download_link_query.rb+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/download_link_query.rb@@ -29,6 +29,7 @@module Storages::Peripherals::StorageInteraction::Nextcloudclass DownloadLinkQuery < Storages::Peripherals::StorageInteraction::StorageQueryinclude API::V3::Utilities::PathHelper+ include Errorsusing Storages::Peripherals::ServiceResultRefinementsdef initialize(base_uri:, token:, retry_proc:)@@ -86,13 +87,6 @@ module Storages::Peripherals::StorageInteraction::Nextcloud# rubocop:enable Metrics/AbcSize- def error(code, log_message = nil, data = nil)- ServiceResult.failure(- result: code, # This is needed to work with the ConnectionManager token refresh mechanism.- errors: Storages::StorageError.new(code:, log_message:, data:)- )- end-def download_link(token, origin_name)api_v3_paths.join_uri_path(@base_uri, 'index.php/apps/integration_openproject/direct', token, CGI.escape(origin_name))enddiff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/errors.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/errors.rbnew file mode 100644index 00000000000..8ed761faae3--- /dev/null+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/errors.rb@@ -0,0 +1,38 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2023 the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#++++module Storages::Peripherals::StorageInteraction::Nextcloud+ module Errors+ def error(code, log_message = nil, data = nil)+ ServiceResult.failure(+ result: code, # This is needed to work with the ConnectionManager token refresh mechanism.+ errors: Storages::StorageError.new(code:, log_message:, data:)+ )+ end+ end+enddiff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/file_query.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/file_query.rbindex 17b75b70fb0..a0f7c44cd31 100644--- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/file_query.rb+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/file_query.rb@@ -29,6 +29,7 @@module Storages::Peripherals::StorageInteraction::Nextcloudclass FileQuery < Storages::Peripherals::StorageInteraction::StorageQueryinclude API::V3::Utilities::PathHelper+ include Errorsusing Storages::Peripherals::ServiceResultRefinementsFILE_INFO_PATH = 'ocs/v1.php/apps/integration_openproject/fileinfo'.freezediff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/upload_link_query.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/upload_link_query.rbindex 030425ef9d0..f5e8522bb8c 100644--- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/upload_link_query.rb+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/upload_link_query.rb@@ -29,6 +29,7 @@module Storages::Peripherals::StorageInteraction::Nextcloudclass UploadLinkQuery < Storages::Peripherals::StorageInteraction::StorageQueryinclude API::V3::Utilities::PathHelper+ include Errorsusing Storages::Peripherals::ServiceResultRefinements # use '>>' (bind) operator for ServiceResultURI_TOKEN_REQUEST = 'index.php/apps/integration_openproject/direct-upload-token'.freeze@@ -115,13 +116,7 @@ module Storages::Peripherals::StorageInteraction::Nextcloud# rubocop:enable Style/OpenStructUse Style/MultilineBlockChainendend- # rubocop:enable Metrics/AbcSize- def error(code, log_message = nil, data = nil)- ServiceResult.failure(- result: code, # This is needed to work with the ConnectionManager token refresh mechanism.- errors: Storages::StorageError.new(code:, log_message:, data:)- )- end+ # rubocop:enable Metrics/AbcSizeendend