Changeset 8390
- Timestamp:
- 12/14/07 23:09:46 (10 months ago)
- Files:
-
- trunk/activeresource/CHANGELOG (modified) (1 diff)
- trunk/activeresource/lib/active_resource/connection.rb (modified) (2 diffs)
- trunk/activeresource/test/connection_test.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activeresource/CHANGELOG
r8364 r8390 1 1 *SVN* 2 3 * Added more specific exceptions for 400, 401, and 403 (all descending from ClientError so existing rescues will work) #10326 [trek] 2 4 3 5 * Correct empty response handling. #10445 [seangeo] trunk/activeresource/lib/active_resource/connection.rb
r8364 r8390 26 26 # 4xx Client Error 27 27 class ClientError < ConnectionError; end # :nodoc: 28 29 # 400 Bad Request 30 class BadRequest < ClientError; end # :nodoc 31 32 # 401 Unauthorized 33 class UnauthorizedAccess < ClientError; end # :nodoc 34 35 # 403 Forbidden 36 class ForbiddenAccess < ClientError; end # :nodoc 28 37 29 38 # 404 Not Found … … 111 120 when 200...400 112 121 response 122 when 400 123 raise(BadRequest.new(response)) 124 when 401 125 raise(UnauthorizedAccess.new(response)) 126 when 403 127 raise(ForbiddenAccess.new(response)) 113 128 when 404 114 129 raise(ResourceNotFound.new(response)) trunk/activeresource/test/connection_test.rb
r7719 r8390 39 39 end 40 40 41 # 400 is a bad request (e.g. malformed URI or missing request parameter) 42 assert_response_raises ActiveResource::BadRequest, 400 43 44 # 401 is an unauthorized request 45 assert_response_raises ActiveResource::UnauthorizedAccess, 401 46 47 # 403 is a forbidden requst (and authorizing will not help) 48 assert_response_raises ActiveResource::ForbiddenAccess, 403 49 41 50 # 404 is a missing resource. 42 51 assert_response_raises ActiveResource::ResourceNotFound, 404 … … 52 61 53 62 # 4xx are client errors. 54 [40 1, 499].each do |code|63 [402, 499].each do |code| 55 64 assert_response_raises ActiveResource::ClientError, code 56 65 end