Skip to content

Commit 32f715f

Browse files
author
Nicholas Newberry
committed
create ApiCalls before checking response error
1 parent 3c93af8 commit 32f715f

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

app/lib/chromadb/client.rb

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,41 +101,38 @@ def _collections
101101
end
102102

103103
def get(path)
104-
Rails.logger.info("[CHROMADB] GET #{path}")
105104
@last_response = HTTParty.get(url(path), headers: { "Content-Type" => "application/json" })
106105

106+
store_api_call("chromadb", @last_response)
107+
107108
unless @last_response.success?
108109
raise ResponseError, @last_response.body
109110
end
110111

111-
store_api_call("chromadb", @last_response)
112-
113112
@last_response.parsed_response
114113
end
115114

116115
def post(path, body = {})
117-
Rails.logger.info("[CHROMADB] POST #{path}")
118116
@last_response = HTTParty.post(url(path), headers: { "Content-Type" => "application/json" }, body: body.to_json)
119117

118+
store_api_call("chromadb", @last_response)
119+
120120
unless @last_response.success?
121121
raise ResponseError, @last_response.body
122122
end
123123

124-
store_api_call("chromadb", @last_response)
125-
126124
@last_response.parsed_response
127125
end
128126

129127
def delete(path)
130-
Rails.logger.info("[CHROMADB] DELETE #{path}")
131128
@last_response = HTTParty.delete(url(path), headers: { "Content-Type" => "application/json" })
132129

130+
store_api_call("chromadb", @last_response)
131+
133132
unless @last_response.success?
134133
raise ResponseError, @last_response.body
135134
end
136135

137-
store_api_call("chromadb", @last_response)
138-
139136
@last_response.parsed_response
140137
end
141138

0 commit comments

Comments
 (0)