Improve error handling
authorHugo Villeneuve <hugo@hugovil.com>
Sat, 28 Feb 2015 22:36:21 +0000 (17:36 -0500)
committerHugo Villeneuve <hugo@hugovil.com>
Sun, 2 Jan 2022 22:43:17 +0000 (17:43 -0500)
src/batmon.c

index c8781e1..d4aa03a 100644 (file)
@@ -76,6 +76,9 @@ static void read_ac_status(void)
 
        if (ac_file == NULL) {
                perror(ac_file_path);
+               fprintf(stderr,
+                       "Unable to find power supply AC online status.\n");
+               exit(EXIT_FAILURE);
        } else {
                while (!feof(ac_file)) {
                        memset(ac_file_line, 0, 40);
@@ -106,6 +109,9 @@ static void read_battery_status(void)
 
        if (batt_file == NULL) {
                perror(batt_file_path);
+               fprintf(stderr,
+                       "Unable to determine battery capacity.\n");
+               exit(EXIT_FAILURE);
        } else {
                while (!feof(batt_file)) {
                        memset(batt_file_line, 0, 40);