git.iko.soy/typeable/bloodhound
on master help sign in
make respIsTwoHunna more semantic

This is actually the cause of a bug in real code. If you happen to be using parseEsResponse (which uses respIsTwoHunna) to parse the result of certain operations such as creating an index, those operations return a 201 and unjustly are deemed to be a failure. I will not disclose how long this took me to figure out the true cause ;)

commitb389fc567b346daf5a1f6cda0f2d5851bc711f8c authorMichael Xavier <michael@michaelxavier.net> dateThu 21 Jan 2016, 17:20 (11 years ago) parent218b407
1 file changed+3−3
src/Database/Bloodhound/Client.hs+3−3
src/Database/Bloodhound/Client.hs+3−3
@@ -309,11 +309,11 @@ deepMerge = LS.foldl' go mempty
309309 merge _ b = b
310310
311311
312−statusCodeIs :: Int -> Reply -> Bool
313−statusCodeIs n resp = NHTS.statusCode (responseStatus resp) == n
312+statusCodeIs :: (Int, Int) -> Reply -> Bool
313+statusCodeIs r resp = inRange r $ NHTS.statusCode (responseStatus resp)
314314
315315respIsTwoHunna :: Reply -> Bool
316−respIsTwoHunna = statusCodeIs 200
316+respIsTwoHunna = statusCodeIs (200, 299)
317317
318318existentialQuery :: MonadBH m => Text -> m (Reply, Bool)
319319existentialQuery url = do