let catch func handler =
  match func () with | (`Ok _ as r) -> r | `Error e -> handler e