C++ (Qt)void MyObject::mySlot(){ try { .... } SUPPRESS_EXCEPTIONS}
void connectToDataBase(){ try { connect(); } catch (const NetworkError& e) { // здесь выполняем локальную обработку throw DataBaseConnectionError(e.what()); }}
class EvenNumber{ int value() const { ... } void setValue(int value) { if (value % 1) throw InvalidParameterException(UserReadableAndLocalizedDescrioptionOfTheProglem); .... } void setValue(const QString& value) { int intValue = convertStringToInt(value); // throws InvalidConversionError setValue(value); }}class Dialog : public Dialog{public: Dialog(EventNumber& dataToBeModified) : dataToBeModified_(dataToBeModified) { ... }private: EventNumber& dataToBeModified_; void lineEditEditingFinished() { dataToBeModified_.setValue(lineEdit->text()); }};
if (value % 1) emit error();