diff options
author | Ryan Kavanagh <rak@rak.ac> | 2020-06-12 22:36:10 -0400 |
---|---|---|
committer | Ryan Kavanagh <rak@rak.ac> | 2020-06-12 22:36:10 -0400 |
commit | 4541e48f22aac7d3073d14bedc9aad69a092a375 (patch) | |
tree | 57841ca3cc709d324a4e2cf7c6cc5653c0249986 /bin | |
parent | Use tlsutils to connect (diff) |
Better error handling
Diffstat (limited to '')
-rw-r--r-- | bin/leda.ml | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/bin/leda.ml b/bin/leda.ml index 98e6244..c32f3a5 100644 --- a/bin/leda.ml +++ b/bin/leda.ml @@ -16,7 +16,7 @@ module R = Gemini.GeminiTransaction.GeminiTransaction(T)(Gemini.TlsUtils.TlsUtil let () = Lwt_main.run begin let%lwt () = Mirage_crypto_rng_lwt.initialize () in - let request : (R.request, string) Base.Result.t = R.make_request (Sys.get_argv()).(1) in + let request = R.make_request (Sys.get_argv()).(1) in let rec loop t = match%lwt Lwt_stream.next (Term.events t) with | `Key _ -> Lwt.return () @@ -44,8 +44,18 @@ let () = let%lwt () = Term.image t (h <-> c) in let%lwt () = Term.refresh t in loop t - | Error m -> + | Error R.TOO_MANY_REDIRECTS -> let%lwt () = Term.release t in - Lwt_io.printl m) - | Error m -> Lwt_io.printl m + Lwt_io.printl "Too many redirects" + | Error (R.X_DOMAIN_REDIR _) -> + let%lwt () = Term.release t in + Lwt_io.printl ("Attempted to redirect across domains") + | Error (UNKNOWN_RESPONSE s) -> + let%lwt () = Term.release t in + Lwt_io.printl ("Unknown response: " ^ s) + | Error (MISC s) -> + let%lwt () = Term.release t in + Lwt_io.printl ("Error: " ^ s)) + | Error m -> + Lwt_io.printl m end |