Exception: MSGraph::Error
- Inherits:
-
StandardError
- Object
- StandardError
- MSGraph::Error
- Defined in:
- lib/msgraph/error.rb
Overview
Error from Microsoft Graph.
Instance Attribute Summary collapse
-
#body ⇒ String, Hash
readonly
The parsed body of the response in JSON case, otherwise the raw body.
-
#error ⇒ Hash
readonly
The parsed error property.
-
#response ⇒ Net::HTTPResponse
readonly
The HTTP response.
Instance Method Summary collapse
-
#initialize(res) ⇒ Error
constructor
A new instance of Error.
Constructor Details
#initialize(res) ⇒ Error
Returns a new instance of Error.
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.}\n#{@body}") end |
Instance Attribute Details
#body ⇒ String, Hash (readonly)
Returns 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 |
#error ⇒ Hash (readonly)
Returns the parsed error property.
12 13 14 |
# File 'lib/msgraph/error.rb', line 12 def error @error end |
#response ⇒ Net::HTTPResponse (readonly)
Returns the HTTP response.
7 8 9 |
# File 'lib/msgraph/error.rb', line 7 def response @response end |