1/*
2 * Copyright (c) 2017, Matias Fontanini
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following disclaimer
13 * in the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 */
29
30#include "exceptions.h"
31
32using std::string;
33using std::to_string;
34
35namespace cppkafka {
36
37// Exception
38
39Exception::Exception(string message)
40: message_(move(message)) {
41
42}
43
44const char* Exception::what() const noexcept {
45 return message_.data();
46}
47
48// ConfigException
49
50ConfigException::ConfigException(const string& config_name, const string& error)
51: Exception("Failed to set " + config_name + ": " + error) {
52
53}
54
55// ConfigOptionNotFound
56
57ConfigOptionNotFound::ConfigOptionNotFound(const string& config_name)
58: Exception(config_name + " not found") {
59
60}
61
62// InvalidConfigOptionType
63
64InvalidConfigOptionType::InvalidConfigOptionType(const string& config_name, const string& type)
65: Exception(config_name + " could not be converted to " + type) {
66
67}
68
69// ElementNotFound
70
71ElementNotFound::ElementNotFound(const string& element_type, const string& name)
72: Exception("Could not find " + element_type + " for " + name) {
73
74}
75
76// ParseException
77
78ParseException::ParseException(const string& message)
79: Exception(message) {
80
81}
82
83// UnexpectedVersion
84
85UnexpectedVersion::UnexpectedVersion(uint32_t version)
86: Exception("Unexpected version " + to_string(version)) {
87}
88
89// HandleException
90
91HandleException::HandleException(Error error)
92: Exception(error.to_string()), error_(error) {
93
94}
95
96Error HandleException::get_error() const {
97 return error_;
98}
99
100// ConsumerException
101
102ConsumerException::ConsumerException(Error error)
103: Exception(error.to_string()), error_(error) {
104
105}
106
107Error ConsumerException::get_error() const {
108 return error_;
109}
110
111// QueueException
112
113QueueException::QueueException(Error error)
114: Exception(error.to_string()), error_(error) {
115
116}
117
118Error QueueException::get_error() const {
119 return error_;
120}
121
122} // cppkafka
123