Skip to content

Commit f7c40e9

Browse files
committed
let ranges be ranges, also don't throw exceptions on 404
1 parent 72f02f2 commit f7c40e9

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/esdb/resource.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module ESDB
22
class Resource < RestClient::Resource
3-
attr_accessor :params
3+
attr_accessor :params, :response
44

55
def initialize(url=nil, options={}, *args)
66
options[:headers] ||= {}
@@ -47,14 +47,15 @@ def self.find(id)
4747
resource = self.new(id: id)
4848
resource.get!
4949

50-
if [200..207].include?(resource.response.code)
50+
if (200..207).include?(resource.response.code)
5151
return resource
5252
else
5353
return nil
5454
end
5555

56-
rescue
57-
raise ESDB::Exception
56+
rescue => e
57+
raise ESDB::Exception if e.response && e.response.code != 404
58+
nil
5859
end
5960

6061
# A kind of find_or_create - experimental.

0 commit comments

Comments
 (0)