1 #ifndef _libslic3r_Exception_h_ 2 #define _libslic3r_Exception_h_ 3 4 #include <stdexcept> 5 6 namespace Slic3r { 7 8 // PrusaSlicer's own exception hierarchy is derived from std::runtime_error. 9 // Base for Slicer's own exceptions. 10 class Exception : public std::runtime_error { using std::runtime_error::runtime_error; }; 11 #define SLIC3R_DERIVE_EXCEPTION(DERIVED_EXCEPTION, PARENT_EXCEPTION) \ 12 class DERIVED_EXCEPTION : public PARENT_EXCEPTION { using PARENT_EXCEPTION::PARENT_EXCEPTION; } 13 // Critical exception produced by Slicer, such exception shall never propagate up to the UI thread. 14 // If that happens, an ugly fat message box with an ugly fat exclamation mark is displayed. 15 SLIC3R_DERIVE_EXCEPTION(CriticalException, Exception); 16 SLIC3R_DERIVE_EXCEPTION(RuntimeError, CriticalException); 17 SLIC3R_DERIVE_EXCEPTION(LogicError, CriticalException); 18 SLIC3R_DERIVE_EXCEPTION(InvalidArgument, LogicError); 19 SLIC3R_DERIVE_EXCEPTION(OutOfRange, LogicError); 20 SLIC3R_DERIVE_EXCEPTION(IOError, CriticalException); 21 SLIC3R_DERIVE_EXCEPTION(FileIOError, IOError); 22 SLIC3R_DERIVE_EXCEPTION(HostNetworkError, IOError); 23 SLIC3R_DERIVE_EXCEPTION(ExportError, CriticalException); 24 SLIC3R_DERIVE_EXCEPTION(PlaceholderParserError, RuntimeError); 25 // Runtime exception produced by Slicer. Such exception cancels the slicing process and it shall be shown in notifications. 26 SLIC3R_DERIVE_EXCEPTION(SlicingError, Exception); 27 #undef SLIC3R_DERIVE_EXCEPTION 28 29 } // namespace Slic3r 30 31 #endif // _libslic3r_Exception_h_ 32