Permalink
Browse files

Add ClosedError message to the initializer

  • Loading branch information...
1 parent 2e757bc commit 90ecad0bc944fc3adb847c0c754d8f0dc2bed4b5 @spastorino spastorino committed Apr 6, 2011
@@ -60,6 +60,7 @@ module ActionDispatch
autoload :Static
end
+ autoload :ClosedError, 'action_dispatch/middleware/closed_error'
autoload :MiddlewareStack, 'action_dispatch/middleware/stack'
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 @@ def initialize(flash)
def close!; @closed = true end
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.discard(k)
v
@@ -84,7 +84,7 @@ def initialize #:nodoc:
def close!; @closed = true end
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)
super
end
@@ -208,7 +208,4 @@ def call(env)
end
end
end
-
- class ClosedError < StandardError #:nodoc:
- end
end

0 comments on commit 90ecad0

Please sign in to comment.