Exception: CanvasSync::JobBatches::RedisScript::LuaError
- Inherits:
-
StandardError
- Object
- StandardError
- CanvasSync::JobBatches::RedisScript::LuaError
- Defined in:
- lib/canvas_sync/job_batches/redis_script.rb
Overview
Reformats errors raised by redis representing failures while executing a lua script. The default errors have confusing messages and backtraces, and a type of RuntimeError
. This class improves the message and modifies the backtrace to include the lua script itself in a reasonable way.
Constant Summary collapse
- PATTERN =
/ERR Error (compiling|running) script \(.*?\): .*?:(\d+): (.*)/
- WOLVERINE_LIB_PATH =
File.('../../', __FILE__)
- CONTEXT_LINE_NUMBER =
2
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Class Method Summary collapse
-
.intercepts?(error) ⇒ Boolean
Is this error one that should be reformatted?.
Instance Method Summary collapse
-
#initialize(error, file, content) ⇒ LuaError
constructor
Initialize a new LuaError from an existing redis error, adjusting the message and backtrace in the process.
Constructor Details
#initialize(error, file, content) ⇒ LuaError
Initialize a new CanvasSync::JobBatches::RedisScript::LuaError from an existing redis error, adjusting the message and backtrace in the process.
117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/canvas_sync/job_batches/redis_script.rb', line 117 def initialize error, file, content @error = error @file = file @content = content @error. =~ PATTERN _stage, line_number, = $1, $2, $3 error_context = generate_error_context(content, line_number.to_i) super "#{}\n\n#{error_context}\n\n" set_backtrace generate_backtrace file, line_number end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
101 102 103 |
# File 'lib/canvas_sync/job_batches/redis_script.rb', line 101 def content @content end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
101 102 103 |
# File 'lib/canvas_sync/job_batches/redis_script.rb', line 101 def error @error end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
101 102 103 |
# File 'lib/canvas_sync/job_batches/redis_script.rb', line 101 def file @file end |
Class Method Details
.intercepts?(error) ⇒ Boolean
Is this error one that should be reformatted?
107 108 109 |
# File 'lib/canvas_sync/job_batches/redis_script.rb', line 107 def self.intercepts? error error. =~ PATTERN end |