Thanks Thomas, that's very clear and it's now handling the error (just
working out how to suppress a log that comes with the error.

And thanks David, I've raised a PR
https://github.com/mirage/ocaml-github/issues/113

On 5 May 2016 at 12:13, Thomas Leonard <[email protected]> wrote:

> On 5 May 2016 at 12:01, Joel Hughes <[email protected]> wrote:
> > Morning all,
> >
> > I was hoping to get some pointers to good/simple examples of
> error-handling
> > in Lwt.
> >
> > After yesterday's call I started looking at getting latest "tag" rather
> than
> > "release" using ocaml-github - Github's API's concept of a release is
> > distinct from git tagging, which explains some repos showing no releases.
> >
> > The approach is fine for repos that have tags but
> > Github.Repo.get_tags_and_times raises an Lwt exception for repos without
> any
> > tags.
> >
> >
> https://github.com/rudenoise/mirage-dashboard/blob/tags/src/get_releases.ml#L66
> >
> > I'd like to get my head around how I could catch this exception and
> swallow
> > it (as needed during the cycle through each repo) - returning a default
> > value/message.
> >
> > Does anyone have a link to a very simple example or tutorial, I'm having
> > trouble finding one?
>
> I'll let someone else answer about whether the API should be changed,
> but given that it does raise, you can handle it like this:
>
>  Lwt.catch
>   (fun () -> call_that_might_raise ...)
>   (function
>    | Error_you_want_to_catch -> handle error here
>    | ex -> Lwt.fail ex  (* Pass others on *)
>   )
>
> > Thanks
> >
> > Joel
> >
> > _______________________________________________
> > MirageOS-devel mailing list
> > [email protected]
> > http://lists.xenproject.org/cgi-bin/mailman/listinfo/mirageos-devel
> >
>
>
>
> --
> Dr Thomas Leonard        http://roscidus.com/blog/
> GPG: DA98 25AE CAD0 8975 7CDA  BD8E 0713 3F96 CA74 D8BA
>
_______________________________________________
MirageOS-devel mailing list
[email protected]
http://lists.xenproject.org/cgi-bin/mailman/listinfo/mirageos-devel

Reply via email to