Sha256: cd49e1c0467f0522ab2c883fb00efbf914c9ac3eaefd46450c8273f84eee4609
Contents?: true
Size: 793 Bytes
Versions: 2
Compression:
Stored size: 793 Bytes
Contents
class Midori::Sandbox class << self def class_initialize @handlers = Hash.new @handlers[Midori::Error::InternalError] = proc {|_e| Midori::Response.new(500, {}, 'Internal Server Error')} @handlers[Midori::Error::NotFound] = proc {|_e| Midori::Response.new(404, {}, '404 Not Found')} end def add_rule(class_name, block) @handlers[class_name] = block end def capture(error) if @handlers[error.class].nil? @handlers[Midori::Error::InternalError].call(error) else @handlers[error.class].call(error) end end def run(clean_room, function, *args) begin function.to_lambda(clean_room).call(*args) rescue StandardError => e capture(e) end end end class_initialize end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
em-midori-0.1.3 | lib/em-midori/sandbox.rb |
em-midori-0.1.2 | lib/em-midori/sandbox.rb |