Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

[PATCH] 410 Gone as ResourceGone for ActiveResource

#2316

Our app needs to distinguish between unknown entities & removed entities. It would be nice if ActiveResource had a ResourceGone error class so that we could do this:


rescue ActiveResource::ResourceGone => e
  ..
end

instead of:


rescue ActiveResource::ClientError => e
  if e.response.code.to_i == 410
    ...
  else
    raise
  end
end

Attached is a patch to do this.

Reported by Jordan Brough · March 23rd, 2009 @ 06:48 PM

State: resolved
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. Jordan Brough
    Jordan Brough
    • Assigned user cleared.

    April 9th, 2009 @ 09:04 PM

  2. CancelProfileIsBroken
    CancelProfileIsBroken
    • Tag changed from activeresource, patch to activeresource, bugmash, patch

    August 6th, 2009 @ 01:36 PM

  3. Jatinder Singh
    Jatinder Singh

    +1 it works cleanly on 2.3-stable. Changes to exists? should indeed take ResourceGone exception into account.

    I added a missing test, but can't create a patch, until https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets... gets out of the door.

    August 9th, 2009 @ 06:18 AM

  4. Jatinder Singh
    Jatinder Singh

    I've attached a patch for a missing test to the patch by Jordan.

    August 9th, 2009 @ 06:58 AM

  5. Kieran P
    Kieran P
    • Title changed from 410 Gone as ResourceGone for ActiveResource to [PATCH] 410 Gone as ResourceGone for ActiveResource

    August 9th, 2009 @ 07:09 AM

  6. Rizwan Reza
    Rizwan Reza

    verified

    +1 The patch by Jatinder applies to 2-3-stable only. All tests pass.

    August 9th, 2009 @ 04:19 PM

  7. Elad Meidar
    Elad Meidar

    +1 Verified, applies and tests pass on 2-3-stable.

    Attached patch and tests for master (my name appears on the commit, i didn't know how to credit the original author, sorry).

    August 9th, 2009 @ 08:52 PM

  8. Repository
    Repository
    • State changed from new to resolved

    (from [916b18adeb0a1ae09fdaff21dda8d0bc8ed4ffa9]) Active Resource recognizes 410 as Resource Gone now [#2316 [PATCH] 410 Gone as ResourceGone for ActiveResource state:resolved] [Jordan Brough, Jatinder Singh]

    Signed-off-by: Pratik Naik pratiknaik@gmail.com
    http://github.com/rails/rails/commit/916b18adeb0a1ae09fdaff21dda8d0...

    August 9th, 2009 @ 10:56 PM

  9. Jeremy Kemper
    Jeremy Kemper
    • Tag changed from activeresource, bugmash, patch to activeresource, patch

    Worth backporting to 2-3-stable?

    August 9th, 2009 @ 11:29 PM

  10. Repository
    Repository

    (from [be017fd7d54c9203dc574d8e1a6f22d80df0e899]) Active Resource recognizes 410 as Resource Gone now [#2316 [PATCH] 410 Gone as ResourceGone for ActiveResource state:resolved] [Jordan Brough, Jatinder Singh]

    Signed-off-by: Pratik Naik pratiknaik@gmail.com

    Conflicts:

    activeresource/lib/active_resource/exceptions.rb
    

    Signed-off-by: Pratik Naik pratiknaik@gmail.com
    http://github.com/rails/rails/commit/be017fd7d54c9203dc574d8e1a6f22...

    August 9th, 2009 @ 11:34 PM