12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- //
- // Created by Иван_Архипов on 31.10.2017.
- //
- #ifndef LOTRO_DAT_PATCHER_DATEXCEPTION_H
- #define LOTRO_DAT_PATCHER_DATEXCEPTION_H
- //#define DAT_DEBUG
- #include <string>
- #include <iostream>
- #include <cstring>
- extern "C++"
- {
- namespace LOTRO_DAT
- {
- enum DAT_EXCEPTION_TYPE {
- INIT_EXCEPTION,
- READ_EXCEPTION,
- WRITE_EXCEPTION,
- SUBDIR_EXCEPTION,
- SUBFILE_EXCEPTION,
- IMPORT_EXCEPTION,
- EXPORT_EXCEPTION,
- DATA_EXCEPTION,
- DATABASE_EXCEPTION,
- LOCALE_EXCEPTION,
- NOFILE_EXCEPTION,
- UNKNOWN_EXCEPTION
- };
- class DatException : public std::exception {
- public:
- DatException()
- : msg_(const_cast<char *>("Unknown DatException has been raised!"))
- , type_(UNKNOWN_EXCEPTION)
- {}
- explicit DatException(const char *msg, DAT_EXCEPTION_TYPE type = UNKNOWN_EXCEPTION) noexcept
- : std::exception()
- , type_(type)
- {
- msg_ = new char[strlen(msg) + 1];
- memcpy(msg_, msg, strlen(msg) + 1);
- #ifdef DAT_DEBUG
- fprintf(stderr, "%s\n", msg_);
- #endif
- }
- ~DatException() override
- {
- delete[] msg_;
- }
- const char* what() const noexcept override
- {
- return "DatException";
- }
- DAT_EXCEPTION_TYPE type() const
- {
- return type_;
- }
- private:
- char *msg_;
- const DAT_EXCEPTION_TYPE type_;
- };
- }
- }
- #endif //LOTRO_DAT_PATCHER_DATEXCEPTION_H
|