Exception: MSIDP::Error
- Inherits:
-
StandardError
- Object
- StandardError
- MSIDP::Error
- Defined in:
- lib/msidp/error.rb
Overview
Error from Microsoft identity platform.
Instance Attribute Summary collapse
-
#body ⇒ String, Hash
readonly
The parsed body of the HTTP response in JSON case, otherwise the raw body.
-
#description ⇒ String
readonly
The error description.
-
#error ⇒ String
readonly
The error code.
-
#response ⇒ Net::HTTPResponse
readonly
The HTTP response.
Instance Method Summary collapse
-
#initialize(response) ⇒ Error
constructor
A new instance of Error.
Constructor Details
#initialize(response) ⇒ Error
Returns a new instance of Error.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/msidp/error.rb', line 17 def initialize(response) @response = response if response.content_type&.start_with? 'application/json' @body = JSON.parse(response.body, symbolize_names: true) @error = @body[:error] @description = @body[:error_description] super(<<-"MSG" #{response.code}: #{response.} #{@error}: #{@description} MSG ) else @body = response.body super(<<-"MSG" #{response.code}: #{response.} #{@body} MSG ) end end |
Instance Attribute Details
#body ⇒ String, Hash (readonly)
Returns the parsed body of the HTTP response in JSON case, otherwise the raw body.
10 11 12 |
# File 'lib/msidp/error.rb', line 10 def body @body end |
#description ⇒ String (readonly)
Returns the error description.
14 15 16 |
# File 'lib/msidp/error.rb', line 14 def description @description end |
#error ⇒ String (readonly)
Returns the error code.
12 13 14 |
# File 'lib/msidp/error.rb', line 12 def error @error end |
#response ⇒ Net::HTTPResponse (readonly)
Returns the HTTP response.
7 8 9 |
# File 'lib/msidp/error.rb', line 7 def response @response end |