From 659bdeee2746742c78501ee1a4d32744c728576c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20A=2E=20Ortega?= Date: Tue, 14 Feb 2017 12:57:11 +0100 Subject: [PATCH] Handle export errors. --- src/main.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index 5300ca4..b2c3ce5 100644 --- a/src/main.c +++ b/src/main.c @@ -114,7 +114,13 @@ int main(int argc, char *argv[]) { printUsage(argv[0]); return 0; } else if(efile && dfile) { - exportPrimes(efile, dfile, base); + int err = exportPrimes(efile, dfile, base); + if(err) { + if(err == 1) fprintf(stderr, "Error: failed to open files.\n"); + else if(err == 2) fprintf(stderr, "Error: failed to close files.\n"); + else if(err == 3) fprintf(stderr, "Error: failed to write to export file.\n"); + return 1; + } return 0; }