Class: RippleKeycloak::ErrorHandler
- Inherits:
-
Object
- Object
- RippleKeycloak::ErrorHandler
- Defined in:
- lib/ripple_keycloak/error_handler.rb
Class Method Summary collapse
Class Method Details
.error_map ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/ripple_keycloak/error_handler.rb', line 6 def error_map { 'Realm does not exist' => RealmDoesNotExistError, 'unauthorized_client' => , 'HTTP 401 Unauthorized' => , 'Could not find role' => RoleNotFoundError, 'User not found' => UserNotFoundError } end |
.raise_error(response) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ripple_keycloak/error_handler.rb', line 16 def raise_error(response) formatted_error = { code: response.code, body: response.parsed_response } raise RippleKeycloak::ConflictError, formatted_error if response.code == 409 raise RippleKeycloak::Error, formatted_error unless response.key? 'error' error_class = error_map[response['error']] raise error_class, formatted_error unless error_class.nil? raise RippleKeycloak::Error, formatted_error end |