I am having problems with rescue actions. Currently using ‘development’
and it is sending e-mails no problem but it still drives me to the error
page…
My specific error at this point is
ActionController::InvalidAuthenticityToken
and I am using an expired session to generate the errors.
in application.rb I have…
this part doesn’t seem to work
def rescue_action_in_public(exception)
if exception == “ActionController::InvalidAuthenticityToken”
flash[:notice]=“Your session expired”
redirect_to :controller => ‘login’, :action => ‘login’
else
flash[:notice]=“The Application Server dumped”
request.env[“HTTP_REFERER”]
redirect_to :back
end
end
this part works…I get the e-mails
protected
Provides code to create an email generated upon error
def log_error(exception)
super(exception)
begin
ErrorMailer.deliver_snapshot(
exception,
clean_backtrace(exception),
session.instance_variable_get("@data"),
params,
request.env)
rescue => e
logger.error(e)
end
end
Craig
–
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
On Oct 4, 8:50 pm, Craig W. [email protected] wrote:
I am having problems with rescue actions. Currently using ‘development’
and it is sending e-mails no problem but it still drives me to the error
page…
My specific error at this point is
ActionController::InvalidAuthenticityToken
and I am using an expired session to generate the errors.
Your if statement is bogus, you’re just comparing an exception object
with a string. Try using is_a? to see if the exception object is an
instance of a given exception class. See also rescue_from
Fred
Fred
On Sun, 2009-10-04 at 13:33 -0700, Frederick C. wrote:
this part doesn’t seem to work
session.instance_variable_get("@data"),
params,
request.env)
rescue => e
logger.error(e)
end
end
Craig
I’ve been looking at rescue_from (API)
I figured out that part of my problem is rescue_action_in_public doesn’t
fly for development which is fine because I can remove ‘in_public’ while
testing in development.
so far, if exception == “ActionController::InvalidAuthenticityToken”
seems to be functioning as I would actually expect.
Craig
–
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
On Sun, 2009-10-04 at 14:07 -0700, Craig W. wrote:
exception,
values either (well, I know if the session is deleted, I wouldn’t get
and similar for @env but both return empty sections.
but similar using @params does return values.
something changed in Rails 2.3.2 and @params and @env are good but
@session seems to be nil - even when there is an active session.
If someone wants to toss me a bone here, I will adjust my code but for
now, I just commented out the @session section so I can move on.
Craig
–
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
On Oct 5, 4:52 am, Craig W. [email protected] wrote:
On Sun, 2009-10-04 at 14:07 -0700, Craig W. wrote:
On Sun, 2009-10-04 at 12:50 -0700, Craig W. wrote:
something changed in Rails 2.3.2 and @params and @env are good but
@session seems to be nil - even when there is an active session.
If someone wants to toss me a bone here, I will adjust my code but for
now, I just commented out the @session section so I can move on.
Session handling was in large part rewritten for 2.3.2 - assumptions
like there being an instance variable called @data almost certainly
no longer hold.
Fred
On Sun, 2009-10-04 at 12:50 -0700, Craig W. wrote:
session.instance_variable_get("@data"),
params,
request.env)
rescue => e
logger.error(e)
end
end
as long as I am at this, I don’t seem to get the environment or session
values either (well, I know if the session is deleted, I wouldn’t get
any values but when I have an error in a valid session, I would expect
to get the session values but I don’t. @session and @env seem to
generate errors.
I have this code in error_mailer.rb
<% for key, val in @session -%>
<%= key %>
<%= val.to_yaml.to_a.join("
\n
") %>
<% end -%>
and similar for @env but both return empty sections.
but similar using @params does return values.
Craig
–
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
On Mon, 2009-10-05 at 00:39 -0700, Frederick C. wrote:
If someone wants to toss me a bone here, I will adjust my code but for
now, I just commented out the @session section so I can move on.
Session handling was in large part rewritten for 2.3.2 - assumptions
like there being an instance variable called @data almost certainly
no longer hold.
I don’t know about ‘assumptions’ but I know that all of the previous
‘how-to’ error notification wikis primarily do this…
in a protected area of your application.rb
def log_error(exception)
super(exception)
begin
ErrorMailer.deliver_snapshot(
exception,
clean_backtrace(exception),
session.instance_variable_get("@data"),
params,
request.env)
rescue => e
logger.error(e)
end
end
so it appears that
session.instance_variable_get("@data")
gets me nothing of value and I wanted the current session hash here, but
I don’t know how to get this from the changed Rails.
Yes, this is definitely changed in Rails 2.3 and pretty much every error
notification I have found on the Internet now is broken.
Craig
–
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
On 5 Oct 2009, at 15:14, Craig W. wrote:
notification I have found on the Internet now is broken.
If I were you I’d stick a breakpoint somewhere around there and fiddle
with the session object to see what it’s got.
Fred