diff options
author | Micah Anderson <micah@riseup.net> | 2015-02-03 15:34:34 -0500 |
---|---|---|
committer | Micah Anderson <micah@riseup.net> | 2015-02-03 15:34:34 -0500 |
commit | 726b3a8145eee81eb55faebdbec40ed0e1b4e819 (patch) | |
tree | 53ebce1a78cd108ec009dcc00c0ef220d77abdff | |
parent | 0fbe82d154d5dc7e4e56251bfdaf3b06563ee3e6 (diff) |
update couch-doc-update to use a more specific exception check (#6699)
-rw-r--r-- | files/couch-doc-update | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/files/couch-doc-update b/files/couch-doc-update index bc23fd9..62d04e6 100644 --- a/files/couch-doc-update +++ b/files/couch-doc-update @@ -120,9 +120,8 @@ def update_document(db, doc, data) doc.reject! {|k,v| !["_id", "_rev"].include? k} doc.merge! data db.save_doc(doc) -rescue RestClient::Exception => e - case e.response.code - when 500, 422 then +rescue RestClient::ExceptionWithResponse => e + if [500, 422].include?(e.response.code) raise if attempt > 5 attempt += 1 sleep 10 @@ -134,9 +133,8 @@ def create_document(db, doc_id, data) attempt ||= 1 data["_id"] = doc_id db.save_doc(data) -rescue RestClient::Exception => e - case e.response.code - when 500, 422 then +rescue RestClient::ExceptionWithResponse => e + if [500, 422].include?(e.response.code) raise if attempt > 5 attempt += 1 sleep 10 |