Exception: Gitea::Api::ServerError
- Inherits:
-
Common::Exception
- Object
- RuntimeError
- Common::Exception
- Gitea::Api::ServerError
- Defined in:
- lib/gitea/api/exception.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#error_code ⇒ Object
readonly
Returns the value of attribute error_code.
-
#http_code ⇒ Object
readonly
Returns the value of attribute http_code.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Instance Method Summary collapse
-
#initialize(response) ⇒ ServerError
constructor
A new instance of ServerError.
- #to_s ⇒ Object
Constructor Details
#initialize(response) ⇒ ServerError
Returns a new instance of ServerError.
7 8 9 10 11 |
# File 'lib/gitea/api/exception.rb', line 7 def initialize(response) @http_code = response.code @attrs = JSON.parse(response.body) rescue {} @message = @attrs['message'] end |
Instance Attribute Details
#error_code ⇒ Object (readonly)
Returns the value of attribute error_code.
5 6 7 |
# File 'lib/gitea/api/exception.rb', line 5 def error_code @error_code end |
#http_code ⇒ Object (readonly)
Returns the value of attribute http_code.
5 6 7 |
# File 'lib/gitea/api/exception.rb', line 5 def http_code @http_code end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
5 6 7 |
# File 'lib/gitea/api/exception.rb', line 5 def @message end |
Instance Method Details
#to_s ⇒ Object
13 14 15 16 17 18 |
# File 'lib/gitea/api/exception.rb', line 13 def to_s @attrs.delete('documentation_url') @attrs.merge({'HTTPCode' => @http_code}).map do |k, v| [k, v].join(": ") end.join(", ") end |