Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: "Milan Stanojević" <milanst@gmail.com>
To: Ollie Frolovs <ollie.frolovs.2012@my.bristol.ac.uk>
Cc: caml users <caml-list@inria.fr>
Subject: Re: [Caml-list] Extracting exception details (Async, Cohttp, Exn)
Date: Mon, 2 Dec 2013 10:14:41 -0500	[thread overview]
Message-ID: <CAKR7PS87vUYsXTFYiEJhLt_uF6XqJzY6-BrY7q0KNC=jWgCvNQ@mail.gmail.com> (raw)
In-Reply-To: <2405FBD1-B79A-4C23-8886-FB6A17D5F8EA@my.bristol.ac.uk>

> Indeed. By saying “description” I tried to communicate my intention, obviously unsuccessfully. In the given example, I would like to extract ("connection attempt timeout" 127.0.0.2:80) in some civil way, preferable as a string so that i can display the error message to the user. In RWO all examples that i have seen so far, just check for Error/None and print “Unexpected failure” to the user (DuckDuckGo example). I want to give more information but not the entire sexp with the backtrace, etc.
>

As I said, you can use Monitor.extract_exn.

try_with (fun () -> Cohttp_async.Client.get (Uri.of_string "http://127.0.0.2"))
>>= function
| Error exn ->
  let orig_exn = Monitor.extract_exn exn in
  Exn.to_string orig_exn
| Ok _ -> .....

      reply	other threads:[~2013-12-02 15:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-29 14:34 Ollie Frolovs
2013-12-02  3:45 ` Milan Stanojević
2013-12-02  8:55   ` Ollie Frolovs
2013-12-02 15:14     ` Milan Stanojević [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAKR7PS87vUYsXTFYiEJhLt_uF6XqJzY6-BrY7q0KNC=jWgCvNQ@mail.gmail.com' \
    --to=milanst@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=ollie.frolovs.2012@my.bristol.ac.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox