Exception: CouchRest::Exception
- Inherits:
-
RuntimeError
- Object
- RuntimeError
- CouchRest::Exception
- Defined in:
- lib/couchrest/exceptions.rb
Overview
This is the base CouchRest exception class. Rescue it if you want to catch any exception that your request might raise. You can get the status code by e.http_code, or see anything about the response via e.response. For example, the entire result body (which is probably an HTML error page) is e.response.
Direct Known Subclasses
Instance Attribute Summary collapse
- #message ⇒ Object
-
#response ⇒ Object
Returns the value of attribute response.
Class Method Summary collapse
Instance Method Summary collapse
- #http_body ⇒ Object
- #http_code ⇒ Object
- #http_headers ⇒ Object
-
#initialize(response = nil) ⇒ Exception
constructor
A new instance of Exception.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(response = nil) ⇒ Exception
Returns a new instance of Exception.
46 47 48 49 |
# File 'lib/couchrest/exceptions.rb', line 46 def initialize response = nil @response = response @message = nil end |
Instance Attribute Details
#message ⇒ Object
72 73 74 |
# File 'lib/couchrest/exceptions.rb', line 72 def @message || self.class. end |
#response ⇒ Object
Returns the value of attribute response.
43 44 45 |
# File 'lib/couchrest/exceptions.rb', line 43 def response @response end |
Class Method Details
.default_message ⇒ Object
76 77 78 |
# File 'lib/couchrest/exceptions.rb', line 76 def self. self.name end |
Instance Method Details
#http_body ⇒ Object
60 61 62 |
# File 'lib/couchrest/exceptions.rb', line 60 def http_body @response.body if @response end |
#http_code ⇒ Object
51 52 53 54 |
# File 'lib/couchrest/exceptions.rb', line 51 def http_code # return integer for compatibility @response.status if @response end |
#http_headers ⇒ Object
56 57 58 |
# File 'lib/couchrest/exceptions.rb', line 56 def http_headers @response.headers if @response end |
#inspect ⇒ Object
64 65 66 |
# File 'lib/couchrest/exceptions.rb', line 64 def inspect "#{}: #{http_body}" end |
#to_s ⇒ Object
68 69 70 |
# File 'lib/couchrest/exceptions.rb', line 68 def to_s inspect end |