]> git.ipfire.org Git - location/libloc.git/commitdiff
perl: Improve error messages
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 26 Sep 2019 17:23:43 +0000 (17:23 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 26 Sep 2019 17:23:43 +0000 (17:23 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/perl/Location/Location.xs

index 469e65fc1de0e97fd7265ef2e94fd05e7a1e3bb5..7080fa934db72bc4a94b4ea27670ae5d3673fc8d 100644 (file)
@@ -23,17 +23,18 @@ init(file)
 
                int err = loc_new(&ctx);
                if (err < 0)
-                       croak("Error");
+                       croak("Could not initialize libloc context: %d\n", err);
 
                FILE* f = fopen(file, "r");
                if (!f) {
-                       croak("Could not open file for reading: %s\n", file);
+                       croak("Could not open file for reading: %s: %s\n",
+                               file, strerror(errno));
                }
 
                struct loc_database *db = NULL;
                err = loc_database_new(ctx, &db, f);
                if (err) {
-                       croak("Could not open database: %s\n", file);
+                       croak("Could not read database: %s\n", file);
                }
 
                RETVAL = db;
@@ -59,7 +60,7 @@ get_country_code(db, address)
                loc_network_unref(network);
 
                if (!country_code) {
-                       croak("Could not get the country code\n");
+                       croak("Could not get the country code for %s\n", address);
                }
 
                RETVAL = strdup(country_code);