Sha256: 2ad666bb1e748efb179e9460e4397dd227752ee34e82cc5e23fe6152ba4a940c
Contents?: true
Size: 725 Bytes
Versions: 2
Compression:
Stored size: 725 Bytes
Contents
# frozen_string_literal: true module FriendlyShipping module Services class UpsJson class ApiError < FriendlyShipping::ApiError # @param [RestClient::Exception] cause def initialize(cause) super(cause, parse_message(cause)) end private # @param [RestClient::Exception] error # @return [String] def parse_message(error) return error.message unless error.response parsed_json = JSON.parse(error.response.body) parsed_json.dig("response", "errors")&.map { |response_error| response_error["message"] }&.join(", ") rescue JSON::ParserError, KeyError => _e nil end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
friendly_shipping-0.10.1 | lib/friendly_shipping/services/ups_json/api_error.rb |
friendly_shipping-0.10.0 | lib/friendly_shipping/services/ups_json/api_error.rb |