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:
parent
2e757bc298
commit
90ecad0bc9
3 changed files with 10 additions and 5 deletions
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue