#ifndef SBK_EXCEPTIONWRAPPER_H
#define SBK_EXCEPTIONWRAPPER_H

// Workaround to access protected functions
#ifndef protected
#  define protected public
#endif

#include <exceptionbase.h>

#include <sbkpython.h>

#include <array>
namespace Shiboken { struct AutoDecRef; class GilState; }

class ExceptionWrapper : public Akonadi::Exception
{
public:
    ExceptionWrapper(const ::QByteArray & what);
    ExceptionWrapper(const ::QString & what);
    ExceptionWrapper(const char * what);
    ExceptionWrapper(const ExceptionWrapper &) = delete;
    ExceptionWrapper& operator=(const ExceptionWrapper &) = delete;
    ExceptionWrapper(ExceptionWrapper &&) = delete;
    ExceptionWrapper& operator=(ExceptionWrapper &&) = delete;
    ~ExceptionWrapper() override;

    ::QByteArray type() const override;
    static ::QByteArray sbk_o_type([[maybe_unused]] const char *ownerClassName, [[maybe_unused]] const char *funcName, [[maybe_unused]] Shiboken::GilState &gil, [[maybe_unused]] const Shiboken::AutoDecRef &pyOverride);
    const char * what() const noexcept override;
    static const char * sbk_o_what([[maybe_unused]] const char *ownerClassName, [[maybe_unused]] const char *funcName, [[maybe_unused]] Shiboken::GilState &gil, [[maybe_unused]] const Shiboken::AutoDecRef &pyOverride) noexcept;
    static void pysideInitQtMetaTypes();

    void resetPyMethodCache();

private:
    mutable std::array<PyObject *, 2> m_PyMethodCache = {nullptr, nullptr};
};

#endif // SBK_EXCEPTIONWRAPPER_H
