let to_string = function
| `Wrong_command_line sl ->
fmt "Wrong command line: %s"
(String.concat ~sep:", " (List.map sl ~f:(fmt "%S")))
| `IO _ as io -> IO.error_to_string io
| `System _ as s -> System.error_to_string s
| `Configuration (`Parsing e) ->
fmt "Parsing error in config-file: %S" e
| `Wrong_configuration (`Found f, got) ->
fmt "Wrong configuration: %S → %s" f
(match got with
| `Expected s -> fmt "expected %s" s
| `Exn e -> fmt "exception: %S" (Printexc.to_string e))
| `Database e -> (Trakeva.Error.to_string e)
| `Host e ->
fmt "Host: %s" (Ketrew_host_io.Error.log e |> Log.to_long_string)
| `Target (`Deserilization s) -> fmt "target-deserialization: %s" s
| `Database_unavailable s -> fmt "DB %s" s
| `Not_implemented s -> fmt "Not-impl %S" s
| `Missing_data p -> fmt "missing data at id: %s" p
| `Failed_to_kill msg -> fmt "Failed to kill target: %S" msg
| `Long_running_failed_to_start (id, msg) ->
fmt "Long running %s failed to start: %s" id msg
| `Failure msg -> fmt "Failure: %S" msg
| `Process _ as pe -> Ketrew_unix_process.error_to_string pe
| `Shell _ as se -> System.error_to_string se
| `Volume (`No_size l) ->
fmt "Did not get the size of the volume: %s" (Log.to_long_string l)
| `Deserialization (except, str) ->
fmt "Deserialization: %s (%S)" (Printexc.to_string except) str
| `Start_server_error e -> fmt "Error starting the server: %s" e
| `Stop_server_error e -> fmt "Error stopping the server: %s" e
| `Server_status_error e -> fmt "Error while getting the server's status: %s" e
| `Wrong_http_request (short, long) ->
fmt "Wrong HTTP Request: %s → %s" short long
| `Client (client_error) ->
fmt "Client: %s" (log_client_error client_error |> Log.to_long_string)
| `Dyn_plugin e ->
begin match e with
| `Dynlink_error e ->
fmt "Dynamic plugin linking error: %s" (Dynlink.error_message e)
| `Findlib e ->
fmt "Dynamic plugin findlib error: %s" (Printexc.to_string e)
end