OnixS CME Drop Copy Handler C++ library 5.7.1
API documentation
Loading...
Searching...
No Matches
Error.h
Go to the documentation of this file.
1// Copyright Onix Solutions Limited [OnixS]. All rights reserved.
2//
3// This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
4// and international copyright treaties.
5//
6// Access to and use of the software is governed by the terms of the applicable OnixS Software
7// Services Agreement (the Agreement) and Customer end user license agreements granting
8// a non-assignable, non-transferable and non-exclusive license to use the software
9// for it's own data processing purposes under the terms defined in the Agreement.
10//
11// Except as otherwise granted within the terms of the Agreement, copying or reproduction of any
12// part of this source code or associated reference material to any other location for further
13// reproduction or redistribution, and any amendments to this copyright notice, are expressly
14// prohibited.
15//
16// Any reproduction or redistribution for sale or hiring of the Software not in accordance with
17// the terms of the Agreement is a violation of copyright law.
18//
19
20#pragma once
21
22#include "OnixS/CME/DropCopy/Export.h"
24
25#include <exception>
26#include <string>
27
28namespace OnixS { namespace CME { namespace DropCopy {
29
31struct ONIXS_CME_DROP_COPY_EXPORT KnownErrors
32{
52
54 static Enum deserialize(const char* value);
55
57 static const char* toString(Enum value);
58};
59
62
64class ONIXS_CME_DROP_COPY_EXPORT Error : public std::exception
65{
66public:
68 Error(const std::string& source, ErrorCode code);
69
71 Error(const std::string& source, ErrorCode code, const std::string& description);
72
74 Error(const Error& other);
75
77 virtual ~Error() throw();
78
80 ErrorCode code() const;
81
83 const char* description() const;
84
86 const char* source() const;
87
89 virtual const char* what() const throw();
90
92 std::string toString() const;
93
95 void toString(std::string&) const;
96
98 Error& operator=(const Error& other);
99
100private:
101 enum Traits
102 {
103 SourceMaxLength = 128,
104 DescriptionMaxLength = 1024
105 };
106
107 ErrorCode code_;
108 char source_[SourceMaxLength + 1];
109 char description_[DescriptionMaxLength + 1];
110};
111
112inline ErrorCode Error::code() const
113{
114 return code_;
115}
116
117inline const char* Error::description() const
118{
119 return description_;
120}
121
122inline const char* Error::source() const
123{
124 return source_;
125}
126
127inline std::string Error::toString() const
128{
129 std::string str;
130 toString(str);
131 return str;
132}
133
134}}}
135
136namespace std {
137// Outputs message into standard stream.
138ONIXS_CME_DROP_COPY_EXPORT std::ostream&
139operator<<(std::ostream&, const OnixS::CME::DropCopy::Error&);
140}
Error(const Error &other)
Initializes as clone of another error.
std::string toString() const
String presentation of an error.
Definition Error.h:127
Error(const std::string &source, ErrorCode code, const std::string &description)
Initializes instance with code and description.
const char * source() const
Origin of the error.
Definition Error.h:122
virtual ~Error()
Destruction interface.
ErrorCode code() const
Code of error.
Definition Error.h:112
Error(const std::string &source, ErrorCode code)
Initializes instance with just a code.
virtual const char * what() const
Human readable description of error.
const char * description() const
Human readable description of error.
Definition Error.h:117
KnownErrors::Enum ErrorCode
Error code.
Definition Error.h:61
STL namespace.
std::ostream & operator<<(std::ostream &, const OnixS::CME::DropCopy::Error &)
List of known errors.
Definition Error.h:32
Enum
List of known errors.
Definition Error.h:35
@ Nothing
Indicates absence of error.
Definition Error.h:37
@ NotLicensed
Product is not licensed.
Definition Error.h:43
@ BadConfiguration
Handler configuration is invalid.
Definition Error.h:46
@ Generic
Error has generic nature.
Definition Error.h:40
static const char * toString(Enum value)
Returns string presentation of value.
static Enum deserialize(const char *value)
Returns constant from its text presentation.