#ifndef QTJSONSERIALIZER_EXCEPTION_H #define QTJSONSERIALIZER_EXCEPTION_H #include "qtjsonserializer_global.h" #include #include #include #if !defined(QT_NO_EXCEPTIONS) && QT_CONFIG(future) #include namespace QtJsonSerializer { //! The exception base class to use for this module using ExceptionBase = QException; } #else #include namespace QtJsonSerializer { //! The exception base class to use for this module using ExceptionBase = std::exception; } #endif namespace QtJsonSerializer { class ExceptionPrivate; //! Exception thrown by QJsonSerializer if something goes wrong class Q_JSONSERIALIZER_EXPORT Exception : public ExceptionBase { public: //! The type of a stack of a property trace (name, type) using PropertyTrace = QStack>; //! Constructor with error message Exception(const QByteArray &what); //! @inherit{std::exception::what} const char *what() const noexcept final; //! Returns the error message, without the property trace QByteArray message() const; //! Returns the property trace PropertyTrace propertyTrace() const; //! @inherit{QException::raise} virtual void raise() const override; //! @inherit{QException::clone} virtual ExceptionBase *clone() const override; protected: //! @private QSharedPointer d; }; //! Exception thrown by the serializers if something goes wrong while serializing class Q_JSONSERIALIZER_EXPORT SerializationException : public Exception { public: //! Constructor with error message SerializationException(const QByteArray &what); void raise() const override; ExceptionBase *clone() const override; }; //! Exception thrown by the serializers if something goes wrong while deserializing class Q_JSONSERIALIZER_EXPORT DeserializationException : public Exception { public: //! Constructor with error message DeserializationException(const QByteArray &what); void raise() const override; ExceptionBase *clone() const override; }; } #endif // QTJSONSERIALIZER_EXCEPTION_H