BearParser
Portable Executable parsing library (from PE-bear)
Loading...
Searching...
No Matches
CustomException.h
Go to the documentation of this file.
1#pragma once
2#include "win_hdrs/win_types.h"
3
4#include <exception>
5#include <errno.h>
6#include <QtCore>
7#include <string>
8
9#define UNKNOWN_EXCEPTION (-1)
10
11class CustomException : public std::exception
12{
13public:
14 CustomException(const QString info, const int32_t code = UNKNOWN_EXCEPTION)
15 : std::exception(), m_info(info), m_code(code) { m_strInfo = info.toStdString(); }
16
17 CustomException(const int32_t code)
18 : std::exception(), m_info(""), m_code(code) {}
19
20 virtual ~CustomException() throw () {}
21
22 QString getInfo() { return (m_info.length() > 0) ? m_info : codeToString(); }
23 int getCode() { return m_code; }
24 virtual const char *what() const throw() { return m_strInfo.c_str(); }
25
26protected:
27 virtual QString codeToString() { return ""; } /* for inherited classes */
28 QString m_info;
29 std::string m_strInfo;
30 const int m_code;
31};
32
34{
35public:
36 ParserException(const QString info) : CustomException(info) {}
37};
38
#define UNKNOWN_EXCEPTION
virtual const char * what() const
CustomException(const QString info, const int32_t code=UNKNOWN_EXCEPTION)
CustomException(const int32_t code)
virtual QString codeToString()
virtual ~CustomException()
std::string m_strInfo
ParserException(const QString info)