[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [MirageOS-devel] Handling Lwt exceptions
On 5 May 2016 at 12:01, Joel Hughes <rudenoise@xxxxxxxxx> 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 > MirageOS-devel@xxxxxxxxxxxxxxxxxxxx > 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 MirageOS-devel@xxxxxxxxxxxxxxxxxxxx http://lists.xenproject.org/cgi-bin/mailman/listinfo/mirageos-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |