Zulip bots with Eio

bot improvements

+14 -2
+14 -2
lib/zulip_bot/storage.ml
··· 90 90 Log.warn (fun m -> m "Failed to parse storage response: %s" msg); 91 91 None 92 92 with Eio.Exn.Io (e, _) -> 93 - Log.warn (fun m -> m "Error fetching key %s: %a" key Eio.Exn.pp_err e); 94 - None) 93 + let is_key_not_found = match e with 94 + | Zulip.Error.E err -> 95 + Zulip.Error.code err = Zulip.Error.Bad_request && 96 + String.equal (Zulip.Error.message err) "Key does not exist." 97 + | _ -> false 98 + in 99 + if is_key_not_found then begin 100 + (* Key not found is a normal case, not an error *) 101 + Log.debug (fun m -> m "Key not found in storage: %s" key); 102 + None 103 + end else begin 104 + Log.warn (fun m -> m "Error fetching key %s: %a" key Eio.Exn.pp_err e); 105 + None 106 + end) 95 107 96 108 let set t key value = 97 109 Log.debug (fun m -> m "Storing key: %s" key);