Sha256: 2699ca458dbc40ca7fc0ddb2f75a8cd9b855771ea16c026f35f98ccc72f93a9c
Contents?: true
Size: 1.2 KB
Versions: 2
Compression:
Stored size: 1.2 KB
Contents
module SimpleShipping # Parent error for all SimpleShipping errors. class Error < StandardError; end # Error raises when response does not contain a label. class NoLabelError < Error ; end # Raises when some data is invalid or missing to build a request. class ValidationError < Error # @param model_or_msg [Abstract::Model, String] def initialize(model_or_msg) @message = case model_or_msg when Abstract::Model "Invalid model #{model_or_msg.class}. Validation errors: #{model_or_msg.errors.full_messages.join(', ')}" when String model_or_msg end super(@message) end end # Raised when a remote request fails. class RequestError < Error # @param [Savon::SOAPFault] savon_fault Savon exception def initialize(savon_fault) fault = savon_fault.to_hash[:fault] @message = if fault[:faultcode] # SOAP 1.1 fault. detail = fault[:detail][:errors][:error_detail][:primary_error_code] "#{fault[:faultstring]} (#{detail[:code]}) #{detail[:description]}" elsif fault[:code] # SOAP 1.2 fault. "(#{fault[:code][:value]}) #{fault[:reason][:text]}" end super(@message) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
simple_shipping-0.4.7 | lib/simple_shipping/exceptions.rb |
simple_shipping-0.4.6 | lib/simple_shipping/exceptions.rb |