diff options
author | Clombrong <cromblong@egregore.fun> | 2025-06-28 13:19:39 +0200 |
---|---|---|
committer | Clombrong <cromblong@egregore.fun> | 2025-06-28 16:44:54 +0200 |
commit | 1f7e45684ab4b3858937d5d5b7b3b883c37f5603 (patch) | |
tree | 9321d72b033ab862b3beacb88f26b5193236212d | |
parent | e669dcf80fc7812e33f813ab18239697563205fa (diff) |
feat(test): adapt test to initiate function
-rw-r--r-- | test/hello.ml | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/test/hello.ml b/test/hello.ml index 212d7f2..ef24804 100644 --- a/test/hello.ml +++ b/test/hello.ml @@ -2,15 +2,6 @@ open! Lwt.Syntax open! Lwt.Infix open! Flesh -let program (p : Portal.t) config (features : Stream.features) = - let+ _auth = Sasl.authenticate p config features.mechanisms - in begin match _auth with - | Error (NotAuthorized, Some (_, text)) -> print_endline ("Not authorized: " ^ text) - | Error (MalformedRequest, Some (_, text)) -> print_endline ("Malformed request: " ^ text) - | Error _ -> print_endline "Error!" - | Ok _ -> print_endline "Success!" - end - let main = let config : Sasl.auth_config = { jid = (Sys.getenv "FLESH_JID"); @@ -18,15 +9,14 @@ let main = preferred_mechanisms = [Sasl.PLAIN] } in let domain = (List.nth (String.split_on_char '@' config.jid) 1) in - let* portal, features = Stream.initiate domain config in - Lwt.catch - (fun () -> program portal config features >|= (fun () -> portal.push None)) - (fun exn -> - portal.push None; + try%lwt Stream.initiate domain config >|= (fun (portal, _) -> portal.push None) + with exn -> + begin (* I suspect JavaScript's [wrap_callback] swallows the Exceptions thrown by OCaml, so... The next best thing is probably printing something. *) print_endline (match exn with | Xml.InvalidStanza stanza -> "Invalid stanza: " ^ stanza | _ -> "... and so I stumble back to bed."); - Lwt.fail exn) + Lwt.fail exn + end |