Module: Fog::Rackspace::Errors
- Included in:
- Compute::Rackspace, Compute::RackspaceV2, DNS::Rackspace, AutoScale, BlockStorage, Databases, LoadBalancers, Monitoring, Queues, Storage::Rackspace
- Defined in:
- lib/fog/rackspace.rb,
lib/fog/rackspace/errors.rb
Defined Under Namespace
Classes: BadRequest, Conflict, InternalServerError, MethodNotAllowed, ServiceError, ServiceUnavailable
Class Method Summary collapse
Class Method Details
.included(mod) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/fog/rackspace/errors.rb', line 5 def self.included(mod) mod.class_eval " class NotFound < Fog::Service::NotFound\n attr_reader :region, :status_code, :transaction_id\n\n def to_s\n status = status_code ? \"HTTP \#{status_code}\" : \"HTTP <Unknown>\"\n message = region ? \"resource not found in \#{region} region\" : super\n \"[\#{status} | \#{transaction_id}] \#{message}\"\n end\n\n def self.slurp(error, service=nil)\n exception = NotFound.new\n exception.instance_variable_set(:@region, service.region) if service && service.respond_to?(:region)\n exception.instance_variable_set(:@status_code, error.response.status) rescue nil\n exception.set_transaction_id(error, service)\n exception\n end\n\n def set_transaction_id(error, service)\n return unless service && service.respond_to?(:request_id_header) && error.response\n @transaction_id = error.response.headers[service.request_id_header]\n end\n\n end\n EOS\nend\n", __FILE__, __LINE__ |