OnixS ICE iMpact Multicast Price Feed Handler C++ library 8.18.0
API documentation
Loading...
Searching...
No Matches
Error.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Onix Solutions Limited. All rights reserved.
3 *
4 * This software owned by Onix Solutions Limited and is protected by copyright law
5 * and international copyright treaties.
6 *
7 * Access to and use of the software is governed by the terms of the applicable ONIXS Software
8 * Services Agreement (the Agreement) and Customer end user license agreements granting
9 * a non-assignable, non-transferable and non-exclusive license to use the software
10 * for it's own data processing purposes under the terms defined in the Agreement.
11 *
12 * Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
13 * of this source code or associated reference material to any other location for further reproduction
14 * or redistribution, and any amendments to this copyright notice, are expressly 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 "Export.h"
23#include "Optional.h"
24#include "Types.h"
25
26#include <iosfwd>
27#include <string>
28
29namespace OnixS { namespace ICE { namespace iMpact { namespace MarketData {
30
32struct ONIXS_ICEMDH_EXPORT KnownErrors
33{
67
69 static const char* toString(Enum value);
70};
71
74
76class ONIXS_ICEMDH_EXPORT Error : public std::exception
77{
78public:
80 Error(const std::string& source, ErrorCode code);
81
83 Error(const std::string& source, ErrorCode code, const std::string& description);
84
86 Error(const std::string& source, ErrorCode code, const std::string& description, FeedId feedId);
87
89 Error(const Error& other);
90
92 virtual ~Error() throw();
93
95 const Optional<FeedId>& feedId() const;
96
98 ErrorCode code() const;
99
101 const char* description() const;
102
104 const char* source() const;
105
107 virtual const char* what() const throw();
108
110 std::string toString() const;
111
113 void toString(std::string&) const;
114
116 Error& operator=(const Error& other);
117
118private:
119 enum Traits
120 {
121 SourceMaxLength = 128,
122 DescriptionMaxLength = 1024
123 };
124
125 ErrorCode code_;
126 char source_[SourceMaxLength];
127 char description_[DescriptionMaxLength];
128 Optional<FeedId> feedId_;
129};
130
132ONIXS_ICEMDH_EXPORT std::ostream& operator<<(std::ostream&, const Error&);
133
134inline const Optional<FeedId>& Error::feedId() const
135{
136 return feedId_;
137}
138
139inline ErrorCode Error::code() const
140{
141 return code_;
142}
143
144inline const char* Error::description() const
145{
146 return description_;
147}
148
149inline const char* Error::source() const
150{
151 return source_;
152}
153
154inline std::string Error::toString() const
155{
156 std::string str;
157 toString(str);
158 return str;
159}
160
161}}}} // namespace OnixS::ICE::iMpact::MarketData
Error(const Error &other)
Initializes as clone of another error.
std::string toString() const
String presentation of an error.
Definition Error.h:154
Error(const std::string &source, ErrorCode code, const std::string &description)
Initializes instance with code and description.
Error(const std::string &source, ErrorCode code, const std::string &description, FeedId feedId)
Initializes instance with code, description and feed ID.
const char * source() const
Origin of the error.
Definition Error.h:149
virtual ~Error()
Destruction interface.
ErrorCode code() const
Code of error.
Definition Error.h:139
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:144
const Optional< FeedId > & feedId() const
Feed ID (if available).
Definition Error.h:134
int FeedId
Alias for market types.
Definition Types.h:33
std::ostream & operator<<(std::ostream &, const Error &)
Make it printable to formatted C++ I/O streams.
KnownErrors::Enum ErrorCode
Error code.
Definition Error.h:73
@ BadMessage
iMpact message has invalid structure.
Definition Error.h:55
@ Nothing
Indicates absence of error.
Definition Error.h:38
@ LogReplayFailure
Indicates irrecoverable log replay failure.
Definition Error.h:62
@ BadConfiguration
Handler configuration is invalid.
Definition Error.h:49
@ BadPacket
Network packet received by the Handler is corrupted.
Definition Error.h:52
@ Generic
Identifiers errors of generic nature.
Definition Error.h:41
@ LoginFailure
Indicates ICE login failure.
Definition Error.h:65
static const char * toString(Enum value)
Returns string presentation of a value.