123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- #ifndef MYSQLX_ERROR_H
- #define MYSQLX_ERROR_H
- #include "common.h"
- #include "detail/error.h"
- #include <memory>
- namespace mysqlx {
- class Warning
- : public virtual common::Printable
- , internal::Warning_detail
- {
- public:
-
- enum Level {
- LEVEL_ERROR,
- LEVEL_WARNING,
- LEVEL_INFO
- };
- private:
- Warning(Level level, uint16_t code, const string &msg)
- : Warning_detail(byte(level),code,msg)
- {
- }
- Warning(Warning_detail &&init)
- : Warning_detail(std::move(init))
- {}
- void print(std::ostream &out) const
- {
- try {
- Warning_detail::print(out);
- }
- CATCH_AND_WRAP
- }
- public:
-
- Level getLevel() const
- {
- return Level(m_level);
- }
-
- uint16_t getCode() const
- {
- return m_code;
- }
-
- const string& getMessage() const
- {
- return m_msg;
- }
-
- friend internal::Result_detail;
-
- struct Access;
- friend Access;
- };
- inline
- void internal::Warning_detail::print(std::ostream &out) const
- {
- switch (Warning::Level(m_level))
- {
- case Warning::LEVEL_ERROR: out << "Error"; break;
- case Warning::LEVEL_WARNING: out << "Warning"; break;
- case Warning::LEVEL_INFO: out << "Info"; break;
- default: out << "<Unknown>"; break;
- }
- if (m_code)
- out << " " << m_code;
- out << ": " << m_msg;
- }
- }
- #endif
|