search for: rescue_from

Displaying 20 results from an estimated 34 matches for "rescue_from".

2009 Feb 10
2
rescue_from for NoMethodError
Hi everyone, I was just trying to catch some exceptions in my app, for "Record Not Found" I used this in my application.rb file rescue_from ActiveRecord::RecordNotFound, :with => :record_not_found rescue_from ActionController::NoMethodError, :with => :show_error private def record_not_found render :text => "404 Not Found", :status => 404 end def show_error(exception) render :text => exception....
2008 Apr 30
7
rescue_from issue with AWS - uninitialized constant
The new rescue_from in edge rails seems to conflict with ActionWebService, which I need for various other purposes. When I define, for example (with AWS gem installed): <b>rescue_from ActionController::RoutingError, :with => :page_not_found</b> I get the exception: <b>uninitialized constant Ac...
2009 Dec 25
18
rescue_from ActionController::RoutingError II
OK ... so I''m not supposed to use it but ... Why doesn''t rescue_from ActionController::RoutingError work witht he code from http://www.rubyplus.org/episodes/20-Extended-RESTful-Authentication-Rails-2-App.html class ApplicationController < ActionController::Base helper :all # include all helpers, all the time # See ActionController::RequestForgeryProtection...
2007 Oct 21
7
exact exceptions in rescue_from
rescue_from stores exception class names in a hash table, and associates them with handlers. When an exception is raised there''s a name lookup, and if an entry is found its handler is invoked. In particular rescue_from does not emulate Ruby''s rescue semantics with regard to inheritance...
2008 Oct 24
1
rescue_from and assert_raise
Since commit 5e3517ea7b9fbd460f772bffc9212d882011f2bc, rescue_from is now being handled in tests. I''ve been using rescue_from to handle custom exceptions and testing that those exceptions are raised in functional tests with assert_raise. This no longer works now. What''s the proper way to test this now? --~--~---------~--~----~------------~----...
2013 Nov 12
7
Hook into Exception Chain
...ct is normally static. I want to set this var to the exception message, so it is sent as the subject. Can anyone tell me how to do this in rails? Basically: raise e or some other cause > -> Log4r::MDC.put(''subject'', e.message) > continue with the exception I found *rescue_from* but it just gives it to the handler and then stops. Thanks a lot, Christoph -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+uns...
2009 Apr 03
0
Truncated development log when using rescue_from
I''m noticing that my development.log messages are not showing the usual complete logging per request/response when I am catching exceptions from my controllers using rescue_from. I was wondering if anyone has ever encountered this issue before. I''m using Rails 2.2.2. Processing DomainsController#show to xml (for 127.0.0.1 at 2009-04-03 16:41:38) [GET] Parameters: {"format"=>"xml", "action"=>"show", "id"=...
2008 Aug 21
1
rescue_from failing to rescue [from]
Having some weird failures of rescue_from in all my specs. They still rescue in actual usage, just not in my specs. Made a pastie of the code: http://pastie.org/257399 This is with latest [as of 1:00 PM Eastern time zone] rspec/rspec-rails/edge. Thanks in advance for any replies on this. RSL -- Posted via http://www.ruby-forum.com/.
2008 Aug 01
1
rescue_from ActionController::MethodNotAllowed
...trouble handing ActionController::MethodNotAllowed errors. Basically, the following is defined in my controllers, but obviously I''m missing something. Thanks in advance for any light you can shed. - - - - - - - - - - - - - - - - - - - - class UsersController < ApplicationController rescue_from ActionController::MethodNotAllowed, :with => :not_allowed def not_allowed flash[:message] = "The action you requested is not supported." redirect_to welcome_path end --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed...
2007 Dec 22
8
Rails 2.0 rescue_from
I am trying to use the new Rails 2.0 macro : rescue_from class PostsController < ApplicationController rescue_from ActiveRecord::RecordNotFound, :with => :deny_access ... def show @post = Post.find_by_id(params[:id]) raise ActiveRecord::RecordNotFound if @post.nil? #illegal access ..... end def deny_access respond_to do |forma...
2008 Sep 02
4
Rescue rails errors
Hi all, Sometime, I get the following error in my application: ActionController::InvalidAuthenticityToken in ManageController#site_servers ActionController::InvalidAuthenticityToken I tried to put the code in manage controller between begin ... rescue ... end but it didn''t catch the error. So I tried in the application.rb controller, I put the forgery code between begin ... rescue ...
2009 Mar 20
1
bypass_rescue and its inverse
...guard clauses, so being able to switch off rescue from (which I properly spec separately) is a real boon. Such a boon, in fact, that I immediately shoved it into a global before :each block so that my controller specs would do what I expect by default. However, that makes my speccing of the rescue_from code a little trickier. Is there an easy way to do the inverse: to switch the default Rails behaviour back on, on command? Thanks, Matt PS I guess the other option is to figure out how to declaratively spec rescue from (which I, and judging by forks of the rspec_on_rails_matchers plugin...
2008 Nov 17
2
Can't seem to test http error codes
in application.rb rescue_from ActiveRecord::RecordNotFound { |e| http_status_code (:missing, e) } def http_status_code(status, exception) @exception = exception respond_to do |format| format.html { render :template => "shared/status_# {status.to_s}", :status => status } format.any { hea...
2008 Feb 07
2
Catching non-Merb::ControllerExceptions Exceptions
Is there an agreed upon method for handling exceptions thrown by something outside of Merb? For example, DataMapper now throws a DataMapper::ObjectNotFoundError when a record isn''t found in the db. I''d like to catch these exceptions and raise a C:E:NotFound exception instead, but without having to wrap a lot of code in begin/rescue/end blocks. Thanks, Mike Irwin
2007 Dec 30
0
Exception not caught while in view
I''m running Rails 2.0.2. My controller is subclassed from RetainController (which is subclassed from ApplicationController). Retain Controller has: rescue_from Retain::LogonFailed, :with => :logon_failed rescue_from Retain::FailedMarkedTrue, :with => :failed_marked_true It works if the exception occurs before I start processing the view. If I get the exception while in the view, (this is in development mode), Rails will give me the usual excep...
2008 Mar 19
2
rescue
Hi, whats the correct way to spec a rescue? This will raise it but doesnt test my code''s response # controller def edit @foo = Foo.find(params[:id]) rescue flash[:notice] = "Unknown foo #{params[:id]}" redirect_to foos_path end # spec it "should flash error if not found" do Foo.should_receive(:find).and_raise get :edit, :id
2011 Jun 05
1
Cancan redirect back at AccessDenied
Hello I have a rails 3 app and I am trying to implement the redirect back action at access denied for cancan. If I try this in my application_controller: rescue_from CanCan::AccessDenied do |exception| redirect_to :back end It gives the following error: No HTTP_REFERER was set in the request to this action, so redirect_to :back could not be called successfully. If this is a test, make sure to specify request.env["HTTP_REFERER"]. I can''t...
2010 Jul 26
2
Exception Pages when behind a proxy
...cker but I also would like to verify that this is in fact a problem. The bug is here: https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/5166-actiondispatchshowexception-always-calls-rescue_action_locally-if-there-is-a-reverse_proxy I believe there is a workaround - you could use rescue_from with StandardError but then you are having to reproduce the exception type to http error code logic. I also think this issue will/should be affecting a bunch of other users as well. Thanks, Adam -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Co...
2010 Aug 08
2
issue with rescue_action_in_public! and testing 404 responses
Hello, I''m new to rails and I''m trying to wrap my heads around how to spec controllers using RSpec (using rails 3rc1 and rspec 2.0.0.beta.19). The problem I''ve run into is when I want to test that my controllers respond with a 404 for unfound records. Whenever I run the spec, the ActiveRecord::RecordNotFound exception is not caught by rails, causing the spec
2010 Mar 28
3
ActionController::UnknownHttpMethod: ***, accepted HTTP methods are get, head, put, post, delete, and options
I''m occasionally getting exception notices with this error message: ActionController::UnknownHttpMethod: ***, accepted HTTP methods are get, head, put, post, delete, and options Anyone ever seen this or know what could be causing it? Thanks, Jeff -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this