Fix code styling [SCI-5531]

This commit is contained in:
Oleksii Kriuchykhin 2021-07-21 13:10:30 +02:00
parent ab9fd65a19
commit 36708b47cf
2 changed files with 8 additions and 7 deletions

View file

@ -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

View file

@ -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'