Class: Aws::SessionStore::DynamoDB::Errors::DefaultHandler
- Inherits:
-
BaseHandler
- Object
- BaseHandler
- Aws::SessionStore::DynamoDB::Errors::DefaultHandler
- Defined in:
- lib/aws/session_store/dynamo_db/errors/default_handler.rb
Overview
This class handles errors raised from DynamoDB.
Constant Summary collapse
- HARD_ERRORS =
Array of errors that will always be passed up the Rack stack.
[ Aws::DynamoDB::Errors::ResourceNotFoundException, Aws::DynamoDB::Errors::ConditionalCheckFailedException, Aws::SessionStore::DynamoDB::Errors::MissingSecretKeyError, Aws::SessionStore::DynamoDB::Errors::LockWaitTimeoutError ].freeze
Instance Method Summary collapse
-
#errors_string(error) ⇒ Object
Returns string to be placed in error stream.
-
#handle_error(error, env = {}) ⇒ Object
Raises HARD_ERRORS up the Rack stack.
-
#initialize(raise_errors) ⇒ DefaultHandler
constructor
Determines behavior of DefaultErrorHandler.
-
#store_error(error, env = {}) ⇒ Object
Sends error to error stream.
Constructor Details
#initialize(raise_errors) ⇒ DefaultHandler
Determines behavior of DefaultErrorHandler
16 17 18 19 |
# File 'lib/aws/session_store/dynamo_db/errors/default_handler.rb', line 16 def initialize(raise_errors) super() @raise_errors = raise_errors end |
Instance Method Details
#errors_string(error) ⇒ Object
Returns string to be placed in error stream
36 37 38 39 40 41 42 |
# File 'lib/aws/session_store/dynamo_db/errors/default_handler.rb', line 36 def errors_string(error) str = [] str << "Exception occurred: #{error.}" str << 'Stack trace:' str += error.backtrace.map { |l| " #{l}" } str.join("\n") end |
#handle_error(error, env = {}) ⇒ Object
Raises HARD_ERRORS up the Rack stack. Places all other errors in Racks error stream.
23 24 25 26 27 28 |
# File 'lib/aws/session_store/dynamo_db/errors/default_handler.rb', line 23 def handle_error(error, env = {}) raise error if HARD_ERRORS.include?(error.class) || @raise_errors store_error(error, env) false end |
#store_error(error, env = {}) ⇒ Object
Sends error to error stream
31 32 33 |
# File 'lib/aws/session_store/dynamo_db/errors/default_handler.rb', line 31 def store_error(error, env = {}) env['rack.errors'].puts(errors_string(error)) if env end |