Exception: OneRosterClient::Error
- Inherits:
-
StandardError
- Object
- StandardError
- OneRosterClient::Error
- Defined in:
- lib/oneroster_client/error.rb
Overview
OneRosterClient error base class
Direct Known Subclasses
Instance Attribute Summary collapse
-
#dependency_name ⇒ String
readonly
Frozen string representing the dependency raising the error.
-
#original_response ⇒ Typhoeus::Response
readonly
The original response object via Typhoeus.
-
#response ⇒ Hash
readonly
:status - Optional integer HTTP response status :headers - String key/value hash of HTTP response header values.
Instance Method Summary collapse
-
#initialize(response = nil, message = nil) ⇒ Error
constructor
Create a new error.
- #message ⇒ Object
-
#to_s ⇒ Object
Override to_s to display a friendly error message.
Constructor Details
#initialize(response = nil, message = nil) ⇒ Error
Create a new error
32 33 34 35 36 37 38 39 |
# File 'lib/oneroster_client/error.rb', line 32 def initialize(response = nil, = nil) @dependency_name = 'OneRoster' @response = { request: {} } @msg = if @original_response = response build_response if response end |
Instance Attribute Details
#dependency_name ⇒ String (readonly)
Frozen string representing the dependency raising the error
27 28 29 |
# File 'lib/oneroster_client/error.rb', line 27 def dependency_name @dependency_name end |
#original_response ⇒ Typhoeus::Response (readonly)
The original response object via Typhoeus
23 24 25 |
# File 'lib/oneroster_client/error.rb', line 23 def original_response @original_response end |
#response ⇒ Hash (readonly)
Returns :status - Optional integer HTTP response status :headers - String key/value hash of HTTP response header
values.
:body - Optional string HTTP response body. :request - Hash
:method - Symbol with the request HTTP method.
:url - URI object with the url requested.
:url_path - String with the url path requested.
:params - String key/value hash of query params
present in the request.
:headers - String key/value hash of HTTP request
header values.
:body - String HTTP request body.
19 20 21 |
# File 'lib/oneroster_client/error.rb', line 19 def response @response end |
Instance Method Details
#message ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/oneroster_client/error.rb', line 46 def if @msg.nil? msg = "Error message: the server returned an error" else msg = @msg end msg += "\nHTTP status code: #{@response[:status]}" if @response[:status] msg += "\nResponse headers: #{@response[:headers]}" if @response[:headers] msg += "\nResponse body: #{@response[:body]}" if @response[:body] msg end |
#to_s ⇒ Object
Override to_s to display a friendly error message
42 43 44 |
# File 'lib/oneroster_client/error.rb', line 42 def to_s end |