Sha256: de3c43106f7339aa7ba736445f11b3a49610dc60381d2c5f3e74d6fadf584ded
Contents?: true
Size: 805 Bytes
Versions: 5
Compression:
Stored size: 805 Bytes
Contents
class Midori::Sandbox class << self def class_initialize @handlers = Hash.new @handlers[Midori::Exception::InternalError] = proc {|_e| Midori::Response.new(500, {}, 'Internal Server Error')} @handlers[Midori::Exception::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::Exception::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
5 entries across 5 versions & 1 rubygems