1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Add ClosedError message to the initializer

This commit is contained in:
Santiago Pastorino 2011-04-06 12:30:08 -03:00
parent 2e757bc298
commit 90ecad0bc9
3 changed files with 10 additions and 5 deletions

View file

@ -60,6 +60,7 @@ module ActionDispatch
autoload :Static autoload :Static
end end
autoload :ClosedError, 'action_dispatch/middleware/closed_error'
autoload :MiddlewareStack, 'action_dispatch/middleware/stack' autoload :MiddlewareStack, 'action_dispatch/middleware/stack'
autoload :Routing autoload :Routing

View file

@ -0,0 +1,7 @@
module ActionDispatch
class ClosedError < StandardError #:nodoc:
def initialize(kind)
super "Cannot modify #{kind} because it was closed. This means it was already streamed back to the client or converted to HTTP headers."
end
end
end

View file

@ -51,7 +51,7 @@ module ActionDispatch
def close!; @closed = true end def close!; @closed = true end
def []=(k, v) def []=(k, v)
raise ClosedError, "Cannot modify flash because it was closed. This means it was already streamed back to the client or converted to HTTP headers." if closed? raise ClosedError, :flash if closed?
@flash[k] = v @flash[k] = v
@flash.discard(k) @flash.discard(k)
v v
@ -84,7 +84,7 @@ module ActionDispatch
def close!; @closed = true end def close!; @closed = true end
def []=(k, v) #:nodoc: def []=(k, v) #:nodoc:
raise ClosedError, "Cannot modify flash because it was closed. This means it was already streamed back to the client or converted to HTTP headers." if closed? raise ClosedError, :flash if closed?
keep(k) keep(k)
super super
end end
@ -208,7 +208,4 @@ module ActionDispatch
end end
end end
end end
class ClosedError < StandardError #:nodoc:
end
end end