let classify_and_transform_errors :
('a, _) Result.t ->
('a, [`Fatal of string | `Recoverable of string ]) Deferred_result.t =
function
| `Ok o -> return o
| `Error e ->
begin match e with
| `Fatal _ as e -> fail e
| `Host he as e ->
begin match Ketrew_host_io.Error.classify he with
| `Ssh | `Unix -> fail (`Recoverable (Error.to_string e))
| `Execution -> fail_fatal (Error.to_string e)
end
| `Timeout _ -> fail (`Recoverable "timeout")
| `IO _ | `System _ as e ->
fail_fatal (Error.to_string e)
end