From 90ecad0bc944fc3adb847c0c754d8f0dc2bed4b5 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 6 Apr 2011 12:30:08 -0300 Subject: Add ClosedError message to the initializer --- actionpack/lib/action_dispatch.rb | 1 + actionpack/lib/action_dispatch/middleware/closed_error.rb | 7 +++++++ actionpack/lib/action_dispatch/middleware/flash.rb | 7 ++----- 3 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 actionpack/lib/action_dispatch/middleware/closed_error.rb diff --git a/actionpack/lib/action_dispatch.rb b/actionpack/lib/action_dispatch.rb index 49971fc9f8..7f972fc281 100644 --- a/actionpack/lib/action_dispatch.rb +++ b/actionpack/lib/action_dispatch.rb @@ -60,6 +60,7 @@ module ActionDispatch autoload :Static end + autoload :ClosedError, 'action_dispatch/middleware/closed_error' autoload :MiddlewareStack, 'action_dispatch/middleware/stack' autoload :Routing diff --git a/actionpack/lib/action_dispatch/middleware/closed_error.rb b/actionpack/lib/action_dispatch/middleware/closed_error.rb new file mode 100644 index 0000000000..0a4db47f4b --- /dev/null +++ b/actionpack/lib/action_dispatch/middleware/closed_error.rb @@ -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 diff --git a/actionpack/lib/action_dispatch/middleware/flash.rb b/actionpack/lib/action_dispatch/middleware/flash.rb index 410d3f7127..6eda1f31a7 100644 --- a/actionpack/lib/action_dispatch/middleware/flash.rb +++ b/actionpack/lib/action_dispatch/middleware/flash.rb @@ -51,7 +51,7 @@ module ActionDispatch 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 @@ module ActionDispatch 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 @@ module ActionDispatch end end end - - class ClosedError < StandardError #:nodoc: - end end -- cgit v1.2.3