Kea 2.5.8
message_exception.h
Go to the documentation of this file.
1// Copyright (C) 2011-2017 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#ifndef MESSAGE_EXCEPTION_H
8#define MESSAGE_EXCEPTION_H
9
11#include <log/message_types.h>
12
13#include <stdexcept>
14#include <string>
15#include <vector>
16
17#include <boost/lexical_cast.hpp>
18
19namespace isc {
20namespace log {
21
27
29public:
30
38 MessageException(const char* file, size_t line, const char* what,
39 MessageID id, int lineno)
40 : isc::Exception(file, line, what), id_(id), lineno_(lineno)
41 {
42 if (lineno_ > 0) {
43 args_.push_back(boost::lexical_cast<std::string>(lineno));
44 }
45 }
46
55 MessageException(const char* file, size_t line, const char* what,
56 MessageID id, const std::string& arg1, int lineno)
57 : isc::Exception(file, line, what), id_(id), lineno_(lineno)
58 {
59 if (lineno > 0) {
60 args_.push_back(boost::lexical_cast<std::string>(lineno));
61 }
62 args_.push_back(arg1);
63 }
64
74 MessageException(const char* file, size_t line, const char *what,
75 MessageID id, const std::string& arg1,
76 const std::string& arg2, int lineno)
77 : isc::Exception(file, line, what), id_(id), lineno_(lineno)
78 {
79 if (lineno > 0) {
80 args_.push_back(boost::lexical_cast<std::string>(lineno));
81 }
82 args_.push_back(arg1);
83 args_.push_back(arg2);
84 }
85
88
92 MessageID id() const {
93 return id_;
94 }
95
99 std::vector<std::string> arguments() const {
100 return (args_);
101 }
102
103private:
104 MessageID id_; // Exception ID
105 std::vector<std::string> args_; // Exception arguments
106 int lineno_;
107};
108
109} // namespace log
110} // namespace isc
111
112#endif // MESSAGE_EXCEPTION_H
This is a base class for exceptions thrown from the DNS library module.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
MessageException(const char *file, size_t line, const char *what, MessageID id, const std::string &arg1, const std::string &arg2, int lineno)
Constructor.
MessageException(const char *file, size_t line, const char *what, MessageID id, int lineno)
Constructor.
MessageException(const char *file, size_t line, const char *what, MessageID id, const std::string &arg1, int lineno)
Constructor.
std::vector< std::string > arguments() const
Return Arguments.
MessageID id() const
Return Message ID.
const char * MessageID
Definition: message_types.h:15
Defines the logger used by the top-level component of kea-lfc.