Sha256: edbb045b72911c3be86b4a3a16f97597e28fed7088a7fa77686bae2764d78b18
Contents?: true
Size: 678 Bytes
Versions: 33
Compression:
Stored size: 678 Bytes
Contents
# frozen_string_literal: true require 'json' module FriendlyShipping module Services class ShipEngine class BadRequest < StandardError attr_reader :rest_error, :response def initialize(rest_error) @rest_error = rest_error @response = rest_error.response super parse_json_errors || rest_error end private def parse_json_errors parsed_body = JSON.parse(response.body) messages = parsed_body.fetch('errors')&.map { |e| e.fetch('message') } messages&.join(', ') rescue JSON::ParserError, KeyError => _e nil end end end end end
Version data entries
33 entries across 33 versions & 1 rubygems