Added handling of std::bad_alloc so the user gets more comprehensible error message
Call to boost::nowide::nowide_filesystem() was made Windows only
This commit is contained in:
parent
bcfb445d0c
commit
1b5d561b7c
@ -60,8 +60,21 @@ PrinterTechnology get_printer_technology(const DynamicConfig &config)
|
||||
|
||||
int CLI::run(int argc, char **argv)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
// Switch boost::filesystem to utf8.
|
||||
boost::nowide::nowide_filesystem();
|
||||
try {
|
||||
boost::nowide::nowide_filesystem();
|
||||
} catch (const std::runtime_error& ex) {
|
||||
std::string caption = std::string(SLIC3R_APP_NAME) + " Error";
|
||||
std::string text = std::string("An error occured while setting up locale.\n") + SLIC3R_APP_NAME + " will now terminate.\n\n" + ex.what();
|
||||
#ifdef SLIC3R_GUI
|
||||
if (m_actions.empty())
|
||||
MessageBoxA(NULL, text.c_str(), caption.c_str(), MB_OK | MB_ICONERROR);
|
||||
#endif
|
||||
boost::nowide::cerr << text.c_str() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (! this->setup(argc, argv))
|
||||
return 1;
|
||||
|
@ -161,7 +161,7 @@ void PrintObject::make_perimeters()
|
||||
const PrintRegion ®ion = *m_print->regions()[region_id];
|
||||
if (! region.config().extra_perimeters || region.config().perimeters == 0 || region.config().fill_density == 0 || this->layer_count() < 2)
|
||||
continue;
|
||||
|
||||
|
||||
BOOST_LOG_TRIVIAL(debug) << "Generating extra perimeters for region " << region_id << " in parallel - start";
|
||||
tbb::parallel_for(
|
||||
tbb::blocked_range<size_t>(0, m_layers.size() - 1),
|
||||
@ -2379,7 +2379,7 @@ void PrintObject::discover_horizontal_shells()
|
||||
if (new_internal_solid.empty()) {
|
||||
// No internal solid needed on this layer. In order to decide whether to continue
|
||||
// searching on the next neighbor (thus enforcing the configured number of solid
|
||||
// layers, use different strategies according to configured infill density:
|
||||
// layers, use different strategies according to configured infill density:
|
||||
if (region_config.fill_density.value == 0) {
|
||||
// If user expects the object to be void (for example a hollow sloping vase),
|
||||
// don't continue the search. In this case, we only generate the external solid
|
||||
|
@ -151,7 +151,12 @@ void BackgroundSlicingProcess::thread_proc()
|
||||
} catch (CanceledException & /* ex */) {
|
||||
// Canceled, this is all right.
|
||||
assert(m_print->canceled());
|
||||
} catch (std::exception &ex) {
|
||||
} catch (const std::bad_alloc& ex) {
|
||||
wxString errmsg = wxString::Format(_(L("%s has encountered an error. It was likely caused by running out of memory. "
|
||||
"If you are sure you have enough RAM on your system, this may also be a bug and we would "
|
||||
"be glad if you reported it.")), SLIC3R_APP_NAME);
|
||||
error = errmsg.ToStdString() + "\n\n" + std::string(ex.what());
|
||||
} catch (std::exception &ex) {
|
||||
error = ex.what();
|
||||
} catch (...) {
|
||||
error = "Unknown C++ exception.";
|
||||
|
@ -126,7 +126,16 @@ static void generic_exception_handle()
|
||||
|
||||
try {
|
||||
throw;
|
||||
} catch (const std::exception &ex) {
|
||||
} catch (const std::bad_alloc& ex) {
|
||||
// bad_alloc in main thread is most likely fatal. Report immediately to the user (wxLogError would be delayed)
|
||||
// and terminate the app so it is at least certain to happen now.
|
||||
wxString errmsg = wxString::Format(_(L("%s has encountered an error. It was likely caused by running out of memory. "
|
||||
"If you are sure you have enough RAM on your system, this may also be a bug and we would "
|
||||
"be glad if you reported it.\n\nThe application will now terminate.")), SLIC3R_APP_NAME);
|
||||
wxMessageBox(errmsg + "\n\n" + wxString(ex.what()), _(L("Fatal error")), wxOK | wxICON_ERROR);
|
||||
BOOST_LOG_TRIVIAL(error) << boost::format("std::bad_alloc exception: %1%") % ex.what();
|
||||
std::terminate();
|
||||
} catch (const std::exception& ex) {
|
||||
wxLogError("Internal error: %s", ex.what());
|
||||
BOOST_LOG_TRIVIAL(error) << boost::format("Uncaught exception: %1%") % ex.what();
|
||||
throw;
|
||||
|
Loading…
Reference in New Issue
Block a user