Skip to content

Commit

Permalink
catch ios_base::failure when reading temps
Browse files Browse the repository at this point in the history
hwmon file might be empty, causing the formatted input function to
throw. Should fix github issue #41 (untested).
  • Loading branch information
Victor Mataré authored and vmatare committed Dec 30, 2019
1 parent 3357a1e commit f23c55c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/thinkfan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ void sig_handler(int signum) {



static void sensor_lost(const SensorDriver *s, const ExpectedError &e) {
static inline void sensor_lost(const SensorDriver *s, const ExpectedError &e) {
if (!s->optional())
error<SensorLost>(e);
else
log(TF_INF) << SensorLost(e).what();
temp_state.add_temp(0);
temp_state.add_temp(-128);
}


Expand Down Expand Up @@ -133,6 +133,8 @@ void run(const Config &config)
sensor_lost(sensor, e);
} catch (IOerror &e) {
sensor_lost(sensor, e);
} catch (std::ios_base::failure &e) {
sensor_lost(sensor, IOerror(e.what(), e.code().value()));
}
}

Expand Down

0 comments on commit f23c55c

Please sign in to comment.