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::MissingSecretKeyError, Aws::SessionStore::DynamoDB::LockWaitTimeoutError ]
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
14 15 16 |
# File 'lib/aws/session_store/dynamo_db/errors/default_handler.rb', line 14 def initialize(raise_errors) @raise_errors = raise_errors end |
Instance Method Details
#errors_string(error) ⇒ Object
Returns string to be placed in error stream
35 36 37 38 39 40 41 |
# File 'lib/aws/session_store/dynamo_db/errors/default_handler.rb', line 35 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.
20 21 22 23 24 25 26 27 |
# File 'lib/aws/session_store/dynamo_db/errors/default_handler.rb', line 20 def handle_error(error, env = {}) if HARD_ERRORS.include?(error.class) || @raise_errors raise error else store_error(error, env) false end end |
#store_error(error, env = {}) ⇒ Object
Sends error to error stream
30 31 32 |
# File 'lib/aws/session_store/dynamo_db/errors/default_handler.rb', line 30 def store_error(error, env = {}) env["rack.errors"].puts(errors_string(error)) if env end |