From 83b07678994d774ebc22cf387229ed7620d7708e Mon Sep 17 00:00:00 2001 From: Clombrong Date: Wed, 11 Jun 2025 17:16:56 +0200 Subject: feat(stream): add ClosedStream exception --- lib/auth.ml | 4 +++- lib/stream.ml | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/auth.ml b/lib/auth.ml index c1486d6..606beb6 100644 --- a/lib/auth.ml +++ b/lib/auth.ml @@ -43,5 +43,7 @@ let send_auth_stanza (stream, push) jid pass mechanism = in Markup.(stanza_list |> of_list |> write_xml |> to_string) |> Option.some |> push; let* response = Lwt_stream.get stream in try - Option.get response |> parse_sasl_response |> Lwt.return + match response with + | Some stanza -> parse_sasl_response stanza |> Lwt.return + | None -> Lwt.fail Stream.ClosedStream with exn -> Lwt.fail exn diff --git a/lib/stream.ml b/lib/stream.ml index 8c7a8f3..25b6822 100644 --- a/lib/stream.ml +++ b/lib/stream.ml @@ -1,5 +1,6 @@ open Lwt.Syntax +exception ClosedStream exception InvalidStanza of string let start domain : Portal.t Lwt.t = -- cgit v1.2.3