aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/hello.ml34
1 files changed, 13 insertions, 21 deletions
diff --git a/test/hello.ml b/test/hello.ml
index a43b90a..55a735e 100644
--- a/test/hello.ml
+++ b/test/hello.ml
@@ -6,30 +6,22 @@ let main =
let config : Stream.config = {
starttls = {prefer = true};
sasl = {
- jid = (Sys.getenv "FLESH_JID");
+ jid = Jid.of_string (Sys.getenv "FLESH_JID");
password = (Sys.getenv "FLESH_PASSWORD");
preferred_mechanisms = [Sasl.PLAIN]
};
other = [];
}
in
- begin
- let jid = Jid.of_string (Sys.getenv "FLESH_JID")
- in
- Option.iter print_endline jid.localpart;
- print_endline jid.domainpart;
- Option.iter print_endline jid.resourcepart;
- end;
- let domain = (List.nth (String.split_on_char '@' config.sasl.jid) 1) in
- try%lwt connect 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
- | Portal.MalformedStanza err -> "Server sent malformed stanza: " ^ (Markup.Error.to_string err)
- | _ -> "... and so I stumble back to bed.");
- Lwt.fail exn
- end
+ try%lwt connect config.sasl.jid.domainpart 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
+ | Portal.MalformedStanza err -> "Server sent malformed stanza: " ^ (Markup.Error.to_string err)
+ | _ -> "... and so I stumble back to bed.");
+ Lwt.fail exn
+ end