diff options
author | Clombrong <cromblong@egregore.fun> | 2025-06-25 15:05:48 +0200 |
---|---|---|
committer | Clombrong <cromblong@egregore.fun> | 2025-06-25 15:05:48 +0200 |
commit | 9bd90b858e01434504daedf27188b8874c87f5d4 (patch) | |
tree | e3b8778926e2d359567c28c93f33ccf9c4f34e51 /portal/ws | |
parent | 8265439154737933d7103a7c2f0a871b475876af (diff) |
fix(portal_websockets): use Lwt exceptions to signal failure
Diffstat (limited to 'portal/ws')
-rw-r--r-- | portal/ws/portal.ml | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/portal/ws/portal.ml b/portal/ws/portal.ml index 3fd142a..527c5f9 100644 --- a/portal/ws/portal.ml +++ b/portal/ws/portal.ml @@ -37,7 +37,7 @@ let stanza_close = {|<close xmlns="|} ^ xmlns ^ {|" />|} |> string |> parse_xml exception MalformedStanza of Markup.location * Markup.Error.t -let ws_endpoint (domain : string) = +let ws_endpoint (domain : string) : string Lwt.t = (** [ws_endpoint domain] is a promise containing the XMPP websocket endpoint associated with [domain], by using the domain's Web-host Metadata. @@ -66,11 +66,11 @@ let ws_endpoint (domain : string) = | _ -> None ) |> Option.join - in let+ host_meta = + in let* host_meta = Js_of_ocaml_lwt.XmlHttpRequest.perform_raw_url (well_known_of domain) in match parse_xrd host_meta.content with - | Some x -> x - | None -> failwith (domain ^ "doesn't advertise a WebSocket endpoint via Web-host Metadata.") + | Some x -> Lwt.return x + | None -> Lwt.fail_with (domain ^ "doesn't advertise a WebSocket endpoint via Web-host Metadata.") let ws_stream (url : string) = (** [ws_stream url] is a promise to a framed Lwt stream (and its push function) |