Exception: Sophos::SG::REST::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/sophos/sg/rest/error.rb

Overview

Copyright 2016 Sophos Technology GmbH. All rights reserved. See the LICENSE.txt file for details. Authors: Vincent Landgraf

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request, response, body) ⇒ Error

Returns a new instance of Error.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/sophos/sg/rest/error.rb', line 8

def initialize(request, response, body)
  @request = request
  @response = response
  @body = body

  message = response.message
  message << ": #{errors.first.name}" if errors.any?
  reqdesc = "#{request.method} #{request.path} -> #{response.code}"

  super "UTM: #{message} (#{reqdesc})"
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



6
7
8
# File 'lib/sophos/sg/rest/error.rb', line 6

def body
  @body
end

#requestObject (readonly)

Returns the value of attribute request.



6
7
8
# File 'lib/sophos/sg/rest/error.rb', line 6

def request
  @request
end

#responseObject (readonly)

Returns the value of attribute response.



6
7
8
# File 'lib/sophos/sg/rest/error.rb', line 6

def response
  @response
end

Instance Method Details

#errorsObject



20
21
22
# File 'lib/sophos/sg/rest/error.rb', line 20

def errors
  body.is_a?(Array) ? body : []
end