Exception handling for too large objects

This commit is contained in:
Lukas Matena 2025-02-13 15:52:26 +01:00
parent 075ff32718
commit 334de30d10
3 changed files with 18 additions and 5 deletions

View File

@ -27,6 +27,8 @@ using namespace Slic3r;
namespace Sequential
{
class ObjectTooLargeException : public std::runtime_error { public: explicit ObjectTooLargeException(const std::string& msg) : std::runtime_error(msg) {}};
class InternalErrorException : public std::runtime_error { public: explicit InternalErrorException(const std::string& msg) : std::runtime_error(msg) {} };

View File

@ -721,7 +721,7 @@ void prepare_ExtruderPolygons(const SolverConfiguration &solver
printf("Object too large to fit onto plate.\n");
}
#endif
throw std::runtime_error("OBJECT TOO LARGE");
throw ObjectTooLargeException("OBJECT TOO LARGE");
}
if (printer_geometry.convex_heights.find(height) != printer_geometry.convex_heights.end())
@ -742,7 +742,7 @@ void prepare_ExtruderPolygons(const SolverConfiguration &solver
}
else
{
throw std::runtime_error("MISMATCH BETWEEN OBJECT AND PRINTER SLICE HEIGHTS.");
throw InternalErrorException("MISMATCH BETWEEN OBJECT AND PRINTER SLICE HEIGHTS.");
}
}
}

View File

@ -8,7 +8,7 @@
#include "slic3r/GUI/I18N.hpp"
#include "slic3r/GUI/Plater.hpp"
#include "slic3r/GUI/MsgDialog.hpp"
#include "slic3r/GUI/format.hpp"
@ -49,8 +49,19 @@ void SeqArrangeJob::finalize(bool canceled, std::exception_ptr& eptr)
try {
std::rethrow_exception(eptr);
} catch (const ExceptionCannotApplySeqArrange&) {
ErrorDialog dlg(wxGetApp().plater(), _L("The result of the single-bed arrange would scatter instances of a single object between several beds, "
"possibly affecting order of printing of the non-selected beds. Consider using global arrange across all beds."), false);
ErrorDialog dlg(wxGetApp().plater(), _L("The result of the single-bed arrange would scatter "
"instances of a single object between several beds, possibly affecting order of printing "
"of the non-selected beds. Consider using global arrange across all beds."), false);
dlg.ShowModal();
error = true;
eptr = nullptr; // The exception is handled.
} catch (const Sequential::ObjectTooLargeException&) {
ErrorDialog dlg(wxGetApp().plater(), _L("One of the objects is too large to fit the bed."), false);
dlg.ShowModal();
error = true;
eptr = nullptr; // The exception is handled.
} catch (const Sequential::InternalErrorException& ex) {
ErrorDialog dlg(wxGetApp().plater(), GUI::format_wxstr(_L("Internal error: %1%"), ex.what()), false);
dlg.ShowModal();
error = true;
eptr = nullptr; // The exception is handled.