Exception: MSGraph::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/msgraph/error.rb

Overview

Error from Microsoft Graph.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(res) ⇒ Error

Returns a new instance of Error.

Parameters:

  • res (Net::HTTPResponse)

    the HTTP response



15
16
17
18
19
20
21
22
23
24
# File 'lib/msgraph/error.rb', line 15

def initialize(res)
  @response = res
  if res.content_type&.start_with? 'application/json'
    @body = JSON.parse(res.body, symbolize_names: true)
    @error = @body[:error]
  else
    @body = res.body
  end
  super("#{res.code}: #{res.message}\n#{@body}")
end

Instance Attribute Details

#bodyString, Hash (readonly)

Returns the parsed body of the response in JSON case, otherwise the raw body.

Returns:

  • (String, Hash)

    the parsed body of the response in JSON case, otherwise the raw body.



10
11
12
# File 'lib/msgraph/error.rb', line 10

def body
  @body
end

#errorHash (readonly)

Returns the parsed error property.

Returns:

  • (Hash)

    the parsed error property.



12
13
14
# File 'lib/msgraph/error.rb', line 12

def error
  @error
end

#responseNet::HTTPResponse (readonly)

Returns the HTTP response.

Returns:

  • (Net::HTTPResponse)

    the HTTP response.



7
8
9
# File 'lib/msgraph/error.rb', line 7

def response
  @response
end