Replaced some of Slic3r::RuntimeError exceptions with Slic3r::SlicingError.

Only Slic3r::SlicingError are now displayed by a notification, other
exceptions are shown by a pop-up dialog.
This commit is contained in:
Vojtech Bubnik 2020-09-14 18:01:25 +02:00
parent 067cde85f1
commit 1eadb6a1a9
5 changed files with 16 additions and 10 deletions

View file

@ -2,7 +2,6 @@
#include "../ClipperUtils.hpp" #include "../ClipperUtils.hpp"
#include "../EdgeGrid.hpp" #include "../EdgeGrid.hpp"
#include "../Exception.hpp"
#include "../Geometry.hpp" #include "../Geometry.hpp"
#include "../Surface.hpp" #include "../Surface.hpp"
#include "../PrintConfig.hpp" #include "../PrintConfig.hpp"

View file

@ -1604,7 +1604,7 @@ void Print::process()
// Initialize the tool ordering, so it could be used by the G-code preview slider for planning tool changes and filament switches. // Initialize the tool ordering, so it could be used by the G-code preview slider for planning tool changes and filament switches.
m_tool_ordering = ToolOrdering(*this, -1, false); m_tool_ordering = ToolOrdering(*this, -1, false);
if (m_tool_ordering.empty() || m_tool_ordering.last_extruder() == unsigned(-1)) if (m_tool_ordering.empty() || m_tool_ordering.last_extruder() == unsigned(-1))
throw Slic3r::RuntimeError("The print is empty. The model is not printable with current print settings."); throw Slic3r::SlicingError("The print is empty. The model is not printable with current print settings.");
} }
this->set_done(psWipeTower); this->set_done(psWipeTower);
} }

View file

@ -139,7 +139,7 @@ void PrintObject::slice()
} }
}); });
if (m_layers.empty()) if (m_layers.empty())
throw Slic3r::RuntimeError("No layers were detected. You might want to repair your STL file(s) or check their size or thickness and retry.\n"); throw Slic3r::SlicingError("No layers were detected. You might want to repair your STL file(s) or check their size or thickness and retry.\n");
this->set_done(posSlice); this->set_done(posSlice);
} }
@ -427,7 +427,7 @@ void PrintObject::generate_support_material()
// therefore they cannot be printed without supports. // therefore they cannot be printed without supports.
for (const Layer *layer : m_layers) for (const Layer *layer : m_layers)
if (layer->empty()) if (layer->empty())
throw Slic3r::RuntimeError("Levitating objects cannot be printed without supports."); throw Slic3r::SlicingError("Levitating objects cannot be printed without supports.");
#endif #endif
} }
this->set_done(posSupportMaterial); this->set_done(posSupportMaterial);

View file

@ -188,7 +188,7 @@ void SLAPrint::Steps::drill_holes(SLAPrintObject &po)
} }
if (MeshBoolean::cgal::does_self_intersect(*holes_mesh_cgal)) if (MeshBoolean::cgal::does_self_intersect(*holes_mesh_cgal))
throw Slic3r::RuntimeError(L("Too many overlapping holes.")); throw Slic3r::SlicingError(L("Too many overlapping holes."));
auto hollowed_mesh_cgal = MeshBoolean::cgal::triangle_mesh_to_cgal(hollowed_mesh); auto hollowed_mesh_cgal = MeshBoolean::cgal::triangle_mesh_to_cgal(hollowed_mesh);
@ -196,7 +196,7 @@ void SLAPrint::Steps::drill_holes(SLAPrintObject &po)
MeshBoolean::cgal::minus(*hollowed_mesh_cgal, *holes_mesh_cgal); MeshBoolean::cgal::minus(*hollowed_mesh_cgal, *holes_mesh_cgal);
hollowed_mesh = MeshBoolean::cgal::cgal_to_triangle_mesh(*hollowed_mesh_cgal); hollowed_mesh = MeshBoolean::cgal::cgal_to_triangle_mesh(*hollowed_mesh_cgal);
} catch (const std::runtime_error &) { } catch (const std::runtime_error &) {
throw Slic3r::RuntimeError(L( throw Slic3r::SlicingError(L(
"Drilling holes into the mesh failed. " "Drilling holes into the mesh failed. "
"This is usually caused by broken model. Try to fix it first.")); "This is usually caused by broken model. Try to fix it first."));
} }
@ -446,7 +446,7 @@ void SLAPrint::Steps::generate_pad(SLAPrintObject &po) {
auto &pad_mesh = po.m_supportdata->support_tree_ptr->retrieve_mesh(sla::MeshType::Pad); auto &pad_mesh = po.m_supportdata->support_tree_ptr->retrieve_mesh(sla::MeshType::Pad);
if (!validate_pad(pad_mesh, pcfg)) if (!validate_pad(pad_mesh, pcfg))
throw Slic3r::RuntimeError( throw Slic3r::SlicingError(
L("No pad can be generated for this model with the " L("No pad can be generated for this model with the "
"current configuration")); "current configuration"));
@ -614,7 +614,7 @@ void SLAPrint::Steps::initialize_printer_input()
for(const SliceRecord& slicerecord : o->get_slice_index()) { for(const SliceRecord& slicerecord : o->get_slice_index()) {
if (!slicerecord.is_valid()) if (!slicerecord.is_valid())
throw Slic3r::RuntimeError( throw Slic3r::SlicingError(
L("There are unprintable objects. Try to " L("There are unprintable objects. Try to "
"adjust support settings to make the " "adjust support settings to make the "
"objects printable.")); "objects printable."));

View file

@ -3524,7 +3524,14 @@ void Plater::priv::on_process_completed(SlicingProcessCompletedEvent &evt)
if (evt.error()) { if (evt.error()) {
std::string message = evt.format_error_message(); std::string message = evt.format_error_message();
//FIXME show a messagebox if evt.critical_error(). if (evt.critical_error()) {
if (q->m_tracking_popup_menu)
// We don't want to pop-up a message box when tracking a pop-up menu.
// We postpone the error message instead.
q->m_tracking_popup_menu_error_message = message;
else
show_error(q, message);
} else
notification_manager->push_slicing_error_notification(message, *q->get_current_canvas3D()); notification_manager->push_slicing_error_notification(message, *q->get_current_canvas3D());
this->statusbar()->set_status_text(from_u8(message)); this->statusbar()->set_status_text(from_u8(message));
const wxString invalid_str = _L("Invalid data"); const wxString invalid_str = _L("Invalid data");