Exception: Gitea::Api::ServerError

Inherits:
Common::Exception show all
Defined in:
lib/gitea/api/exception.rb

Direct Known Subclasses

CallBackError

Instance Attribute Summary collapse

Instance Method Summary collapse

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_codeObject (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_codeObject (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

#messageObject (readonly)

Returns the value of attribute message.



5
6
7
# File 'lib/gitea/api/exception.rb', line 5

def message
  @message
end

Instance Method Details

#to_sObject



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