Class: HCA::SOAPParser
- Inherits:
-
Common::Client::Middleware::Response::SOAPParser
- Object
- Faraday::Middleware
- Common::Client::Middleware::Response::SOAPParser
- HCA::SOAPParser
- Includes:
- SentryLogging
- Defined in:
- lib/hca/soap_parser.rb
Defined Under Namespace
Classes: ValidationError
Constant Summary collapse
- VALIDATION_FAIL_KEY =
'api.hca.validation_fail'
- FAULT_EL =
'S:Envelope/S:Body/ns0:Fault'
- FAULT_STRING_EL =
"#{FAULT_EL}/faultstring".freeze
- FAULT_CODE_EL =
"#{FAULT_EL}/detail/VoaFaultException/faultExceptions/faultException/code".freeze
Instance Method Summary collapse
Methods included from SentryLogging
#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger, #set_sentry_metadata
Methods inherited from Common::Client::Middleware::Response::SOAPParser
#doc_includes_error?, #ensure_xml_prolog, #log_error_details, #parse_doc
Instance Method Details
#on_complete(env) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/hca/soap_parser.rb', line 15 def on_complete(env) super rescue Common::Client::Errors::HTTPError => e if env.status.to_i == 503 raise Faraday::TimeoutError else doc = parse_doc(env.body) el = doc.locate(FAULT_STRING_EL)[0] if el&.nodes.try(:[], 0) == 'formSubmissionException' && doc.locate(FAULT_CODE_EL)[0]&.nodes.try(:[], 0) != 'VOA_0240' StatsD.increment(VALIDATION_FAIL_KEY) Sentry.(validation: 'hca') log_exception_to_sentry(e) raise ValidationError end raise end end |