Module: Inferno::CLI::Session::Errors
- Included in:
- CancelRun, CreateSession, SessionData, SessionDetails, SessionResults, SessionStatus, StartRun
- Defined in:
- lib/inferno/apps/cli/session/errors.rb
Instance Method Summary collapse
- #handle_web_api_error(response, api = nil) ⇒ Object
- #not_found_error_message(api) ⇒ Object
- #parse_error_response(response, api) ⇒ Object
- #test_run_not_found_message(response) ⇒ Object
- #text_error_message(response, api) ⇒ Object
Instance Method Details
#handle_web_api_error(response, api = nil) ⇒ Object
5 6 7 8 9 |
# File 'lib/inferno/apps/cli/session/errors.rb', line 5 def handle_web_api_error(response, api = nil) error = parse_error_response(response, api) puts JSON.pretty_generate(error) exit(3) end |
#not_found_error_message(api) ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/inferno/apps/cli/session/errors.rb', line 27 def (api) case api when :session_create, :run_create "Running Inferno host not found at '#{base_url}'" when :session_details, :session_data, :last_session_run "Session '#{session_id}' not found on Inferno host at '#{base_url}'" else 'Not Found' end end |
#parse_error_response(response, api) ⇒ Object
11 12 13 14 15 |
# File 'lib/inferno/apps/cli/session/errors.rb', line 11 def parse_error_response(response, api) JSON.parse(response.body) rescue JSON::ParserError { errors: (response, api) } end |
#test_run_not_found_message(response) ⇒ Object
38 39 40 41 |
# File 'lib/inferno/apps/cli/session/errors.rb', line 38 def (response) test_run_id = response.env.url.to_s.split('/')[-2] "Test Run '#{test_run_id}' for session '#{session_id}' not found on Inferno host at '#{base_url}'" end |
#text_error_message(response, api) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/inferno/apps/cli/session/errors.rb', line 17 def (response, api) if response.body == 'Not Found' || response.status == 404 (api) elsif api == :test_run_results && response.status == 500 (response) else response.body end end |