aboutsummaryrefslogtreecommitdiffstats
path: root/activeresource/lib/active_resource/connection.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2007-12-14 23:09:46 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2007-12-14 23:09:46 +0000
commit1ceccdeb7f86898a9e511e934ea6b0863d30590d (patch)
tree51df80c22b0ea40c7893e259884be2204339669e /activeresource/lib/active_resource/connection.rb
parentf5c17790e1a16d92d29f60a5b308b3895e5b94c5 (diff)
downloadrails-1ceccdeb7f86898a9e511e934ea6b0863d30590d.tar.gz
rails-1ceccdeb7f86898a9e511e934ea6b0863d30590d.tar.bz2
rails-1ceccdeb7f86898a9e511e934ea6b0863d30590d.zip
Added more specific exceptions for 400, 401, and 403 (all descending from ClientError so existing rescues will work) (closes #10326) [trek]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8390 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activeresource/lib/active_resource/connection.rb')
-rw-r--r--activeresource/lib/active_resource/connection.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/activeresource/lib/active_resource/connection.rb b/activeresource/lib/active_resource/connection.rb
index fba393ff89..2bf83b1615 100644
--- a/activeresource/lib/active_resource/connection.rb
+++ b/activeresource/lib/active_resource/connection.rb
@@ -26,6 +26,15 @@ module ActiveResource
# 4xx Client Error
class ClientError < ConnectionError; end # :nodoc:
+ # 400 Bad Request
+ class BadRequest < ClientError; end # :nodoc
+
+ # 401 Unauthorized
+ class UnauthorizedAccess < ClientError; end # :nodoc
+
+ # 403 Forbidden
+ class ForbiddenAccess < ClientError; end # :nodoc
+
# 404 Not Found
class ResourceNotFound < ClientError; end # :nodoc:
@@ -110,6 +119,12 @@ module ActiveResource
raise(Redirection.new(response))
when 200...400
response
+ when 400
+ raise(BadRequest.new(response))
+ when 401
+ raise(UnauthorizedAccess.new(response))
+ when 403
+ raise(ForbiddenAccess.new(response))
when 404
raise(ResourceNotFound.new(response))
when 405