package ppx_catch

All checked builds pass
  1. Overview
  2. Docs
A PPX rewriter to catch exceptions and wrap into options or results

Install

dune-project
 Dependency

Authors

Maintainers

Sources

0.1.tar.gz
md5=6301b2275bed2f5a7044626000445999
sha512=01efa7eba79053149b6ed424bab10900fbb45f2ffa529229019a425d16610ca839da899d1109e59338d3fd1ba7a28446f214d1e98c7c3c065ba03e6534784356

Description

This package catches all exceptions in a block and returns an option or a result of the resulting value

Added to opam-repository:

README

ppx_catch

ppx_catch is a PPX rewriter to catch exceptions. It acts as a catch-all and transforms expressions into options or results.

Usage

catch.o

The catch.o extension wraps an expression into an option.

[%catch.o
  let i = Option.get None in
  i + 1
]

gives None, while

[%catch.o
  let i = Option.get (Some 2)
  in i + 1
]

gives Some 3. [%catch.o expression] behaves exactly like:

try Some expression with _ -> None

catch.r

The catch.r extension wraps an expression into a result.

[%catch.r Some 10;
  let i = Option.get None in
  i + 1
]

gives Error (Some 10), while

[%catch.r Some 10;
  let i = Option.get (Some 2)
  in i + 1
]

gives Ok 3. [%catch.r err; expression] behaves exactly like:

try Ok expression with _ -> err

Dependencies (3)

  1. ppxlib >= "0.27.0"
  2. dune >= "2.7"
  3. alcotest >= "1.6.0"

Dev Dependencies (1)

  1. odoc with-doc

Optional Dependencies

None

Used by

None

Conflicts

None

Build status

Results of building ppx_catch with each compiler on check.ci.ocaml.org, run of against opam-repository 8a77e58. All results for this package.

Each result links to its build log. To keep crawlers from overloading the site, build logs require a GitHub sign-in (see ocurrent/opam-health-check). On your first log, GitHub asks you to “Authorize opam-health-check”, the OCurrent app that runs these checks; it sees only your public profile, not your repositories. The sign-in lasts 30 days.

Version OCaml 4.11 OCaml 4.14 OCaml 5.2 OCaml 5.4 OCaml 5.5
0.1.0 (this version) good good good good good
  • good Package successfully built
  • partial One of the dependencies failed to build
  • bad Package failed to build
  • n/a Package is not available in this environment
  • internal Internal failure