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é committed May 21, 2018
1 parent 6d9719b commit b0b91c6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/thinkfan.cpp
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 b0b91c6

Please sign in to comment.