Simplify CaptureThread error callback functions.

This commit is contained in:
Jared Boone 2016-06-21 11:13:58 -07:00
parent cfaa44b02a
commit 320d979924
2 changed files with 7 additions and 11 deletions

View File

@ -233,7 +233,7 @@ void RecordView::start() {
filename_stem + ".WAV"
);
if( create_error.is_valid() ) {
report_error(create_error.value().what());
handle_error(create_error.value());
} else {
writer = std::move(p);
}
@ -244,7 +244,7 @@ void RecordView::start() {
{
const auto metadata_file_error = write_metadata_file(filename_stem + ".TXT");
if( metadata_file_error.is_valid() ) {
report_error(metadata_file_error.value().what());
handle_error(metadata_file_error.value());
return;
}
@ -253,7 +253,7 @@ void RecordView::start() {
filename_stem + ".C16"
);
if( create_error.is_valid() ) {
report_error(create_error.value().what());
handle_error(create_error.value());
} else {
writer = std::move(p);
}
@ -326,10 +326,10 @@ void RecordView::on_tick_second() {
}
}
void RecordView::report_error(const std::string& message) {
void RecordView::handle_error(const File::Error error) {
stop();
if( on_error ) {
on_error(message);
on_error(error.what());
}
}

View File

@ -79,7 +79,7 @@ private:
void on_tick_second();
void report_error(const std::string& message);
void handle_error(const File::Error error);
const std::string filename_stem_pattern;
const FileType file_type;
@ -120,13 +120,9 @@ private:
Message::ID::CaptureThreadError,
[this](const Message* const p) {
const auto message = *reinterpret_cast<const CaptureThreadErrorMessage*>(p);
this->on_capture_thread_error(message.error);
this->handle_error(message.error);
}
};
void on_capture_thread_error(File::Error error) {
report_error(error.what());
}
};
} /* namespace ui */