158 lines
4.8 KiB
C++
Executable File
158 lines
4.8 KiB
C++
Executable File
// Copyright Onix Solutions Limited [OnixS]. All rights reserved.
|
|
//
|
|
// This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
|
|
// and international copyright treaties.
|
|
//
|
|
// Access to and use of the software is governed by the terms of the applicable OnixS Software
|
|
// Services Agreement (the Agreement) and Customer end user license agreements granting
|
|
// a non-assignable, non-transferable and non-exclusive license to use the software
|
|
// for it's own data processing purposes under the terms defined in the Agreement.
|
|
//
|
|
// Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
|
|
// of this source code or associated reference material to any other location for further reproduction
|
|
// or redistribution, and any amendments to this copyright notice, are expressly prohibited.
|
|
//
|
|
// Any reproduction or redistribution for sale or hiring of the Software not in accordance with
|
|
// the terms of the Agreement is a violation of copyright law.
|
|
//
|
|
|
|
#pragma once
|
|
|
|
#include "OnixS/CME/MDP3/ABI.h"
|
|
#include "OnixS/CME/MDP3/Types.h"
|
|
|
|
namespace std
|
|
{
|
|
ONIXS_CME_MDP3_API_DECL(class, exception);
|
|
}
|
|
|
|
namespace OnixS
|
|
{
|
|
namespace CME
|
|
{
|
|
namespace MDP3
|
|
{
|
|
/// List of known errors.
|
|
struct ONIXS_CME_MDP3_API KnownErrors
|
|
{
|
|
/// List of known errors.
|
|
enum Enum
|
|
{
|
|
/// Indicates absence of error.
|
|
Nothing,
|
|
|
|
/// Error has generic nature.
|
|
Generic,
|
|
|
|
/// Product is not licensed.
|
|
NotLicensed,
|
|
|
|
/// Handler configuration is invalid.
|
|
BadConfiguration,
|
|
|
|
/// Network packet received by the Handler is corrupted.
|
|
BadPacket,
|
|
|
|
/// FIX message has invalid structure.
|
|
/// E.g. misses some of required fields.
|
|
BadMessage
|
|
};
|
|
|
|
/// Returns string presentation of value.
|
|
static const char* toString(Enum value);
|
|
};
|
|
|
|
/// Error code.
|
|
typedef KnownErrors::Enum ErrorCode;
|
|
|
|
/// Error.
|
|
class
|
|
ONIXS_CME_MDP3_THROWABLE_API
|
|
Error : public std::exception
|
|
{
|
|
public:
|
|
/// Initializes instance with just a code.
|
|
Error(
|
|
const std::string& source,
|
|
ErrorCode code);
|
|
|
|
/// Initializes instance with code and description.
|
|
Error(
|
|
const std::string& source,
|
|
ErrorCode code,
|
|
const std::string& description);
|
|
|
|
/// Initializes as clone of another error.
|
|
Error(const Error& other);
|
|
|
|
/// Destruction interface.
|
|
virtual ~Error() throw();
|
|
|
|
/// Code of error.
|
|
ErrorCode code() const
|
|
{
|
|
return code_;
|
|
}
|
|
|
|
/// Human readable description of error.
|
|
const char* description() const
|
|
{
|
|
return description_;
|
|
}
|
|
|
|
/// Origin of the error.
|
|
const char* source() const
|
|
{
|
|
return source_;
|
|
}
|
|
|
|
/// Human readable description of error.
|
|
virtual const char* what() const throw();
|
|
|
|
/// String presentation of an error.
|
|
std::string toString() const
|
|
{
|
|
std::string str;
|
|
toString(str);
|
|
return str;
|
|
}
|
|
|
|
/// Appends presentation of an error to the string.
|
|
void toString(std::string&) const;
|
|
|
|
/// Copies error attributes from another instance.
|
|
Error& operator =(const Error& other);
|
|
|
|
private:
|
|
enum Traits
|
|
{
|
|
SourceMaxLength = 128,
|
|
DescriptionMaxLength = 1024
|
|
};
|
|
|
|
ErrorCode code_;
|
|
char source_[SourceMaxLength + 1];
|
|
char description_[DescriptionMaxLength + 1];
|
|
};
|
|
|
|
/// Error listener.
|
|
class
|
|
ONIXS_CME_MDP3_API
|
|
ErrorListener
|
|
{
|
|
public:
|
|
/// Is called when an error is detected
|
|
/// during the processing of the market data.
|
|
virtual
|
|
void
|
|
onError(
|
|
const Error& error,
|
|
const ChannelId& channelId) = 0;
|
|
|
|
protected:
|
|
virtual ~ErrorListener();
|
|
};
|
|
}
|
|
}
|
|
}
|