mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-06 11:57:16 +08:00
Fix code styling [SCI-5531]
This commit is contained in:
parent
ab9fd65a19
commit
36708b47cf
2 changed files with 8 additions and 7 deletions
|
@ -48,19 +48,20 @@ class BiomoleculeToolkitClient
|
||||||
private
|
private
|
||||||
|
|
||||||
def process_request(request)
|
def process_request(request)
|
||||||
responce = @http.request(request)
|
response = @http.request(request)
|
||||||
|
|
||||||
if responce.is_a? Net::HTTPOK
|
case response.class
|
||||||
JSON.parse(responce.body)
|
when Net::HTTPOK
|
||||||
elsif responce.is_a? Net::HTTPNoContent
|
JSON.parse(response.body)
|
||||||
|
when Net::HTTPNoContent
|
||||||
true
|
true
|
||||||
else
|
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')
|
error_message ||= I18n.t('biomolecule_toolkit_client.generic_error')
|
||||||
raise BiomoleculeToolkitClientException, error_message
|
raise BiomoleculeToolkitClientException, error_message
|
||||||
end
|
end
|
||||||
rescue JSON::ParserError
|
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
|
rescue StandardError
|
||||||
raise BiomoleculeToolkitClientException, I18n.t('biomolecule_toolkit_client.generic_error')
|
raise BiomoleculeToolkitClientException, I18n.t('biomolecule_toolkit_client.generic_error')
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
en:
|
en:
|
||||||
biomolecule_toolkit_client:
|
biomolecule_toolkit_client:
|
||||||
generic_error: 'Failed to execute API command'
|
generic_error: 'Failed to execute API command'
|
||||||
responce_parsing_error: 'Failed to parse API response'
|
response_parsing_error: 'Failed to parse API response'
|
||||||
|
|
Loading…
Add table
Reference in a new issue