client: Improve error diagnostics.
[paraslash.git] / client.c
index 5f511708506a464e1a0e06f679eaa856ac015164..4998222ea7c89df98ad55879a08f9dea1b5f6c6b 100644 (file)
--- a/client.c
+++ b/client.c
@@ -603,14 +603,22 @@ int main(int argc, char *argv[])
                EMBRACE(.name = "stdout", .parent = ct->btrn));
        register_task(&sched, &svt);
        ret = schedule(&sched);
+       if (ret >= 0 && ct->task.error < 0) {
+               switch(ct->task.error) {
+               /* these are not errors */
+               case -E_EOF:
+               case -E_SERVER_EOF:
+               case -E_BTR_EOF:
+                       ret = 0;
+                       break;
+               default: ret = ct->task.error;
+               }
+       }
 out:
+       if (ret < 0)
+               PARA_ERROR_LOG("%s\n", para_strerror(-ret));
        client_close(ct);
        btr_free_node(sit.btrn);
        btr_free_node(sot.btrn);
-       if (ret < 0) {
-               /* can not use PARA_LOG here because ct is NULL */
-               fprintf(stderr, "%s\n", para_strerror(-ret));
-               return EXIT_FAILURE;
-       }
-       return EXIT_SUCCESS;
+       return ret < 0? EXIT_FAILURE : EXIT_SUCCESS;
 }