Skip to content

Commit 354a301

Browse files
author
ubuntu
committed
improve error message
1 parent d7e5aec commit 354a301

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

include/ccapi_cpp/ccapi_request.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ namespace ccapi {
2828
class Request {
2929
public:
3030
enum class Operation {
31+
UNKNOWN = 0,
3132
CUSTOM = CCAPI_REQUEST_OPERATION_TYPE_CUSTOM,
3233
GENERIC_PUBLIC_REQUEST = CCAPI_REQUEST_OPERATION_TYPE_GENERIC_PUBLIC_REQUEST,
3334
GENERIC_PRIVATE_REQUEST = CCAPI_REQUEST_OPERATION_TYPE_GENERIC_PRIVATE_REQUEST,
@@ -60,6 +61,9 @@ class Request {
6061
case Operation::CUSTOM:
6162
output = "CUSTOM";
6263
break;
64+
case Operation::UNKNOWN:
65+
output = "UNKNOWN";
66+
break;
6367
case Operation::GENERIC_PUBLIC_REQUEST:
6468
output = "GENERIC_PUBLIC_REQUEST";
6569
break;
@@ -130,7 +134,7 @@ class Request {
130134
output = "GET_ACCOUNT_POSITIONS";
131135
break;
132136
default:
133-
CCAPI_LOGGER_FATAL(CCAPI_UNSUPPORTED_VALUE);
137+
CCAPI_LOGGER_FATAL(std::string(CCAPI_UNSUPPORTED_VALUE) + " " + std::to_string(static_cast<int>(operation)));
134138
}
135139
return output;
136140
}
@@ -267,7 +271,7 @@ class Request {
267271

268272
private:
269273
#endif
270-
Operation operation;
274+
Operation operation{Operation::UNKNOWN};
271275
std::string exchange;
272276
std::string marginType;
273277
std::string instrument;

include/ccapi_cpp/ccapi_session.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ class Session {
660660
auto subscriptionList = x.second;
661661
if (this->serviceByServiceNameExchangeMap.find(serviceName) == this->serviceByServiceNameExchangeMap.end()) {
662662
this->onError(Event::Type::SUBSCRIPTION_STATUS, Message::Type::SUBSCRIPTION_FAILURE,
663-
"please enable service: " + serviceName + ", and the exchanges that you want");
663+
"please enable service: " + serviceName + ", and the exchanges that you want for subscriptionList " + toString(subscriptionList));
664664
return;
665665
}
666666
if (serviceName == CCAPI_MARKET_DATA) {
@@ -727,7 +727,8 @@ class Session {
727727
auto serviceName = subscription.getServiceName();
728728
CCAPI_LOGGER_DEBUG("serviceName = " + serviceName);
729729
if (this->serviceByServiceNameExchangeMap.find(serviceName) == this->serviceByServiceNameExchangeMap.end()) {
730-
this->onError(Event::Type::FIX_STATUS, Message::Type::FIX_FAILURE, "please enable service: " + serviceName + ", and the exchanges that you want");
730+
this->onError(Event::Type::FIX_STATUS, Message::Type::FIX_FAILURE,
731+
"please enable service: " + serviceName + ", and the exchanges that you want for subscription " + toString(subscription));
731732
return;
732733
}
733734
auto exchange = subscription.getExchange();
@@ -781,7 +782,8 @@ class Session {
781782
auto serviceName = request.getServiceName();
782783
CCAPI_LOGGER_DEBUG("serviceName = " + serviceName);
783784
if (this->serviceByServiceNameExchangeMap.find(serviceName) == this->serviceByServiceNameExchangeMap.end()) {
784-
this->onError(Event::Type::FIX_STATUS, Message::Type::FIX_FAILURE, "please enable service: " + serviceName + ", and the exchanges that you want");
785+
this->onError(Event::Type::FIX_STATUS, Message::Type::FIX_FAILURE,
786+
"please enable service: " + serviceName + ", and the exchanges that you want for request " + toString(request));
785787
return;
786788
}
787789
std::map<std::string, std::shared_ptr<Service>>& serviceByExchangeMap = this->serviceByServiceNameExchangeMap.at(serviceName);
@@ -807,7 +809,9 @@ class Session {
807809
const auto& serviceName = request.getServiceName();
808810
CCAPI_LOGGER_DEBUG("serviceName = " + serviceName);
809811
if (this->serviceByServiceNameExchangeMap.find(serviceName) == this->serviceByServiceNameExchangeMap.end()) {
810-
this->onError(Event::Type::REQUEST_STATUS, Message::Type::REQUEST_FAILURE, "please enable service: " + serviceName + ", and the exchanges that you want");
812+
this->onError(Event::Type::REQUEST_STATUS, Message::Type::REQUEST_FAILURE,
813+
"please enable service: " + serviceName + ", and the exchanges that you want for websocketOrderEntrySubscriptionCorrelationId " +
814+
toString(websocketOrderEntrySubscriptionCorrelationId) + ", request = " + toString(request));
811815
return;
812816
}
813817
const std::map<std::string, std::shared_ptr<Service>>& serviceByExchangeMap = this->serviceByServiceNameExchangeMap.at(serviceName);
@@ -846,7 +850,7 @@ class Session {
846850
CCAPI_LOGGER_DEBUG("serviceName = " + serviceName);
847851
if (this->serviceByServiceNameExchangeMap.find(serviceName) == this->serviceByServiceNameExchangeMap.end()) {
848852
this->onError(Event::Type::REQUEST_STATUS, Message::Type::REQUEST_FAILURE,
849-
"please enable service: " + serviceName + ", and the exchanges that you want", eventQueuePtr);
853+
"please enable service: " + serviceName + ", and the exchanges that you want for request " + toString(request), eventQueuePtr);
850854
return;
851855
}
852856
std::map<std::string, std::shared_ptr<Service>>& serviceByExchangeMap = this->serviceByServiceNameExchangeMap.at(serviceName);

include/ccapi_cpp/ccapi_subscription.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ class Subscription {
159159
output = "UNSUBSCRIBED";
160160
break;
161161
default:
162-
CCAPI_LOGGER_FATAL(CCAPI_UNSUPPORTED_VALUE);
162+
CCAPI_LOGGER_FATAL(std::string(CCAPI_UNSUPPORTED_VALUE) + " " + std::to_string(static_cast<int>(status)));
163163
}
164164
return output;
165165
}

0 commit comments

Comments
 (0)