Skip to content

Commit

Permalink
bgcode: Propagate errors from valid_for_print
Browse files Browse the repository at this point in the history
If a file fails the valid for print check not because it is still not
downloaded, but because it is somehow broken, report it as such. This
goes all the way to the GUI, instead of the „Downloading“ screen.

BFW-5830.
  • Loading branch information
vorner committed Jul 30, 2024
1 parent 82fb3f3 commit 505b7c2
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/common/gcode/gcode_reader_binary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,25 @@ bool PrusaPackGcodeReader::valid_for_print() {
return IterateResult_t::Continue;
});

if (auto err = std::get_if<Result_t>(&res); err != nullptr) {
switch (*err) {
case Result_t::RESULT_EOF:
set_error(N_("File doesn't contain any print instructions"));
break;
case Result_t::RESULT_CORRUPT:
set_error(N_("File corrupt"));
break;
case Result_t::RESULT_ERROR:
set_error(N_("Unknown file error"));
break;
default:
// All the rest (OK, Timeout, out of range) don't prevent this
// file from being printable in the future, so don't set any
// error.
break;
}
}

return std::holds_alternative<BlockHeader>(res);
}

Expand Down

0 comments on commit 505b7c2

Please sign in to comment.