Sha256: ae9cc93cb433534143fed2149072425a395805f3a3388a5c51d4809e821ef550
Contents?: true
Size: 1.58 KB
Versions: 2
Compression:
Stored size: 1.58 KB
Contents
module GovDelivery::TMS module Request # The generic TMS error class class Error < StandardError attr_reader :code def initialize(code) super("HTTP Error: #{code}") @code=code end end # Raised when a recipient list is still being constructed and a request is made to view the # recipient list for a message. class InProgress < StandardError;end end module Errors class ServerError < StandardError def initialize(response) super("TMS client encountered a server error: #{response.status} \n#{response.body}") end end class NoRelation < StandardError def initialize(rel=nil, obj=nil) message = "no link relation " message << "'#{rel}' " if rel message << 'is available' message << " for #{obj}" if obj super(message) end end class InvalidVerb < StandardError attr_reader :record def initialize(record_or_string) if record_or_string.respond_to?(:href) @record = record_or_string super("Couldn't POST #{record.class} to #{record.href}: #{record.errors.map { |k, v| "#{k} #{v.join(' and ')}" }.join(', ')}") else super(record_or_string) end end end class InvalidPost < InvalidVerb end class InvalidPut < InvalidVerb end class InvalidDelete < InvalidVerb end class InvalidGet < StandardError def initialize(message=nil) super(message || "Can't GET a resource after an invalid POST; either create a new object or fix errors") end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
govdelivery-tms-0.8.2 | lib/govdelivery/tms/errors.rb |
govdelivery-tms-0.8.1 | lib/govdelivery/tms/errors.rb |