lib/ratis/errors.rb in ratis-3.5.0 vs lib/ratis/errors.rb in ratis-3.6.0

- old
+ new

@@ -1,70 +1,74 @@ module Ratis - class Error < StandardError + end - attr_accessor :fault_code, :fault_string + module Errors + class SoapError < Ratis::Error - def initialize(savon_soap_fault = nil) - return if savon_soap_fault.nil? or savon_soap_fault.blank? - fault = savon_soap_fault.to_hash[:fault] - code = fault[:faultcode].scan(/\d+/).first - self.fault_code = code.to_i if code - self.fault_string = fault[:faultstring] - end + attr_accessor :fault_code, :fault_string - # def self.version_mismatch(method, version) - # error = Errors.new - # error.fault_string = "Unimplemented SOAP method #{ method } #{ version }" - # error - # end + def initialize(savon_soap_fault = nil) + return if savon_soap_fault.nil? or savon_soap_fault.blank? + fault = savon_soap_fault.to_hash[:fault] + code = fault[:faultcode].scan(/\d+/).first + self.fault_code = code.to_i if code + self.fault_string = fault[:faultstring] + end - def to_s - fault_string - end + # def self.version_mismatch(method, version) + # error = Errors.new + # error.fault_string = "Unimplemented SOAP method #{ method } #{ version }" + # error + # end - def verbose_fault_string - case fault_string - when /10222|invalid Stopid/i - 'Invalid STOP ID number. Please enter a valid five digit stop ID number' - when /20003|20046/ - 'No stops were found within the walking distance of the origin you specified' - when /20004|20047/ - 'No stops were found within the walking distance of the destination you specified' - when /20048/ - 'No stops were found within the walking distance of the destination or origin you specified' - when /20005/ - 'There is no service at this stop on the date and time specified' - when /20006/ - 'No services run at the date or time specified for your destination' - when /20007/ - 'No trips were found matching the criteria you specified' - when /20008/ - 'No services run at the date or time specified' - when /11085/ - 'Origin is within trivial distance of the destination' - when /15034/ - 'No runs available for the stop and times provided' - when /1007|no runs available/i - 'There is no service at this stop on the date and time specified' - when /15035/ - 'The route you specified does not serve this stop at the date and time specified' - when /invalid Window|15030/i - 'The minimum time range is one hour. Please adjust the start and/or end time and try again.' - when /invalid Location|20024/i - 'Either the origin or destination could not be recognized by the server' - when /out of range/i - 'The date you entered was out of range - please choose a valid date' - else - 'The server could not handle your request at this time. Please try again later' + def to_s + fault_string end + + def verbose_fault_string + case fault_string + when /10222|invalid Stopid/i + 'Invalid STOP ID number. Please enter a valid five digit stop ID number' + when /20003|20046/ + 'No stops were found within the walking distance of the origin you specified' + when /20004|20047/ + 'No stops were found within the walking distance of the destination you specified' + when /20048/ + 'No stops were found within the walking distance of the destination or origin you specified' + when /20005/ + 'There is no service at this stop on the date and time specified' + when /20006/ + 'No services run at the date or time specified for your destination' + when /20007/ + 'No trips were found matching the criteria you specified' + when /20008/ + 'No services run at the date or time specified' + when /11085/ + 'Origin is within trivial distance of the destination' + when /15034/ + 'No runs available for the stop and times provided' + when /1007|no runs available/i + 'There is no service at this stop on the date and time specified' + when /15035/ + 'The route you specified does not serve this stop at the date and time specified' + when /invalid Window|15030/i + 'The minimum time range is one hour. Please adjust the start and/or end time and try again.' + when /invalid Location|20024/i + 'Either the origin or destination could not be recognized by the server' + when /out of range/i + 'The date you entered was out of range - please choose a valid date' + else + 'The server could not handle your request at this time. Please try again later' + end + end end - end - module Errors + class ConfigError < Ratis::Error + end - class ConfigError < StandardError; end - class SoapError < Error; end + class NetworkError < Ratis::Error + include Nesty::NestedError + end end - end