Exception: NaranyaEcm::Rest::AuthorizationRequired

Inherits:
RestError
  • Object
show all
Defined in:
lib/naranya_ecm/rest/errors.rb

Instance Attribute Summary

Attributes inherited from RestError

#response

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from RestError

build_from_failed_response, raise_by_failed_response

Constructor Details

#initialize(given_response, msg = "") ⇒ AuthorizationRequired

Returns a new instance of AuthorizationRequired.



119
120
121
122
123
# File 'lib/naranya_ecm/rest/errors.rb', line 119

def initialize(given_response, msg = "")
  data = parse_www_authenticate_header given_response
  super given_response,
    "#{data['error_description']} (HTTP status #{given_response.status})"
end

Class Method Details

.parse_www_authenticate_header(response) ⇒ Object



112
113
114
115
# File 'lib/naranya_ecm/rest/errors.rb', line 112

def self.parse_www_authenticate_header(response)
  Hash[response.headers['WWW-Authenticate'].scan(/(\w+)="([^"]+)"/)] \
    if response.headers['WWW-Authenticate']
end