Class: Aspera::RestErrorsAspera
- Inherits:
-
Object
- Object
- Aspera::RestErrorsAspera
- Defined in:
- lib/aspera/rest_errors_aspera.rb
Overview
REST error handlers for various Aspera REST APIs
Class Method Summary collapse
-
.register_handlers ⇒ Object
handlers should probably be defined by plugins for modularity.
Class Method Details
.register_handlers ⇒ Object
handlers should probably be defined by plugins for modularity
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/aspera/rest_errors_aspera.rb', line 11 def register_handlers Log.log.debug('registering Aspera REST error handlers') # Faspex 4: both user_message and internal_message, and code 200 # example: missing meta data on package creation RestErrorAnalyzer.instance.add_simple_handler(name: 'Type 1: error:user_message', path: %w[error user_message], always: true) RestErrorAnalyzer.instance.add_simple_handler(name: 'Type 2: error:description', path: %w[error description]) RestErrorAnalyzer.instance.add_simple_handler(name: 'Type 3: error:internal_message', path: %w[error internal_message]) RestErrorAnalyzer.instance.add_simple_handler(name: 'Type 5', path: ['error_description']) RestErrorAnalyzer.instance.add_simple_handler(name: 'Type 6', path: ['message']) # AoC Automation RestErrorAnalyzer.instance.add_simple_handler(name: 'AoC Automation', path: ['error']) RestErrorAnalyzer.instance.add_handler('Type 7: errors[]') do |type, call_context| next unless call_context[:data].is_a?(Hash) && call_context[:data]['errors'].is_a?(Hash) # special for Shares: false positive ? (update global transfer_settings) next if call_context[:data].key?('min_connect_version') call_context[:data]['errors'].each do |k, v| RestErrorAnalyzer.add_error(call_context, type, "#{k}: #{v}") end end # call to upload_setup and download_setup of node api RestErrorAnalyzer.instance.add_handler('T8:node: *_setup') do |type, call_context| next unless call_context[:data].is_a?(Hash) d_t_s = call_context[:data]['transfer_specs'] next unless d_t_s.is_a?(Array) d_t_s.each do |res| r_err = res.dig(*%w[transfer_spec error]) || res['error'] next unless r_err.is_a?(Hash) RestErrorAnalyzer.add_error(call_context, type, "#{r_err['code']}: #{r_err['reason']}: #{r_err['user_message']}") end end RestErrorAnalyzer.instance.add_simple_handler(name: 'T9:IBM cloud IAM', path: ['errorMessage']) RestErrorAnalyzer.instance.add_simple_handler(name: 'T10:faspex v4', path: ['user_message']) RestErrorAnalyzer.instance.add_handler('bss graphql') do |type, call_context| next unless call_context[:data].is_a?(Hash) d_t_s = call_context[:data]['errors'] next unless d_t_s.is_a?(Array) d_t_s.each do |res| r_err = res['message'] next unless r_err.is_a?(String) RestErrorAnalyzer.add_error(call_context, type, r_err) end end RestErrorAnalyzer.instance.add_handler('Orchestrator') do |type, call_context| next if call_context[:response].code.start_with?('2') data = call_context[:data] next unless data.is_a?(Hash) work_order = data['work_order'] next unless work_order.is_a?(Hash) RestErrorAnalyzer.add_error(call_context, type, work_order['statusDetails']) data['missing_parameters']&.each do |param| RestErrorAnalyzer.add_error(call_context, type, "missing parameter: #{param}") end end end |