aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/poco/Redis/include/Poco/Redis/Error.h
blob: ddc8155bd54cb1aef50fba2e9ec627dcbf2aec9f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
//
// Error.h
//
// Library: Redis
// Package: Redis
// Module:  Error
//
// Definition of the Error class.
//
// Copyright (c) 2015, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier:	BSL-1.0
//


#ifndef Redis_Error_INCLUDED
#define Redis_Error_INCLUDED


#include "Poco/Redis/Type.h"


namespace Poco {
namespace Redis {


class Redis_API Error
	/// Represent a Redis error.
{
public:
	Error();
		/// Creates an empty Error.

	Error(const std::string& message);
		/// Creates an Error with the given message.

	virtual ~Error();
		/// Destroys the Error.

	const std::string& getMessage() const;
		/// Returns the error message.

	void setMessage(const std::string& message);
		/// Sets the error message.

private:
	std::string _message;
};


//
// inlines
//


inline const std::string& Error::getMessage() const
{
	return _message;
}


inline void Error::setMessage(const std::string& message)
{
	_message = message;
}


template<>
struct RedisTypeTraits<Error>
{
	enum { TypeId = RedisType::REDIS_ERROR };

	static const char marker = '-';

	static std::string toString(const Error& value)
	{
		return marker + value.getMessage()  + LineEnding::NEWLINE_CRLF;
	}

	static void read(RedisInputStream& input, Error& value)
	{
		value.setMessage(input.getline());
	}
};


} } // namespace Poco::Redis


#endif // Redis_Error_INCLUDED