diff --git a/app/services/biomolecule_toolkit_client.rb b/app/services/biomolecule_toolkit_client.rb index c01f1cdc4..2909c2cc2 100644 --- a/app/services/biomolecule_toolkit_client.rb +++ b/app/services/biomolecule_toolkit_client.rb @@ -48,19 +48,20 @@ class BiomoleculeToolkitClient private def process_request(request) - responce = @http.request(request) + response = @http.request(request) - if responce.is_a? Net::HTTPOK - JSON.parse(responce.body) - elsif responce.is_a? Net::HTTPNoContent + case response.class + when Net::HTTPOK + JSON.parse(response.body) + when Net::HTTPNoContent true else - error_message = JSON.parse(responce.body).dig('error', 'message') + error_message = JSON.parse(response.body).dig('error', 'message') error_message ||= I18n.t('biomolecule_toolkit_client.generic_error') raise BiomoleculeToolkitClientException, error_message end rescue JSON::ParserError - raise BiomoleculeToolkitClientException, I18n.t('biomolecule_toolkit_client.responce_parsing_error') + raise BiomoleculeToolkitClientException, I18n.t('biomolecule_toolkit_client.response_parsing_error') rescue StandardError raise BiomoleculeToolkitClientException, I18n.t('biomolecule_toolkit_client.generic_error') end diff --git a/config/locales/biomolecule_toolkit_client/en.yml b/config/locales/biomolecule_toolkit_client/en.yml index 6739dff13..8ac3858c1 100644 --- a/config/locales/biomolecule_toolkit_client/en.yml +++ b/config/locales/biomolecule_toolkit_client/en.yml @@ -1,4 +1,4 @@ en: biomolecule_toolkit_client: generic_error: 'Failed to execute API command' - responce_parsing_error: 'Failed to parse API response' + response_parsing_error: 'Failed to parse API response'