Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MDAPI-113] [C++][Tools] Tools should report invalid event type #53

Merged
merged 8 commits into from
Jul 24, 2024
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ set(dxFeedGraalCxxApi_InternalUtilsDebug_Sources
)

set(dxFeedGraalCxxApi_Exceptions_Sources
src/exceptions/RuntimeException.cpp
src/exceptions/InvalidArgumentException.cpp
src/exceptions/GraalException.cpp
src/exceptions/JavaException.cpp
)
Expand Down
5 changes: 5 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
* **\[MDAPI-113]\[C++]\[Tools]** Tools should report invalid event type
* Added classes: `RuntimeException`, `InvalidArgumentException`
* `InvalidArgumentException`, `GraalException`, `JavaException` are now descendants of the `RuntimeException` class, which can collect stacktrace.
* Now an `InvalidArgumentException` exception is thrown instead of the `std::invalid_argument` exception.
* `Tools` now reports incorrect event types specified by the user.
* **\[MDAPI-80]\[C++]\[IPF]** Implement custom fields in InstrumentProfile
* The API was migrated to Graal SDK v1.1.22
* Added methods:
Expand Down
2 changes: 2 additions & 0 deletions include/dxfeed_graal_cpp_api/api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ DXFCXX_DISABLE_MSC_WARNINGS_PUSH(4251 4996)

#include "isolated/Isolated.hpp"

#include "exceptions/RuntimeException.hpp"
#include "exceptions/InvalidArgumentException.hpp"
#include "exceptions/JavaException.hpp"
#include "exceptions/GraalException.hpp"

Expand Down
58 changes: 29 additions & 29 deletions include/dxfeed_graal_cpp_api/api/DXEndpoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ struct OnDemandService;
*
* Some methods that are not marked `noexcept` may throw exceptions:
*
* @throws std::invalid_argument if handle is invalid.
* @throws InvalidArgumentException if handle is invalid.
* @throws JavaException if something happened with the dxFeed API backend
* @throws GraalException if something happened with the GraalVM
*/
Expand Down Expand Up @@ -481,7 +481,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared<DXEndpoint> {

// Throws:
// - std::bad_alloc if it was not possible to allocate the required amount of memory
// - std::invalid_argument if endpointHandle is nullptr
// - InvalidArgumentException if endpointHandle is nullptr
// - JavaException if something happened with the dxFeed API backend
// - GraalException if something happened with the GraalVM
static std::shared_ptr<DXEndpoint> create(void *endpointHandle, Role role,
Expand Down Expand Up @@ -509,7 +509,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared<DXEndpoint> {
* @ref DXEndpoint::getInstance(Role) "getInstance"(@ref DXEndpoint "DXEndpoint"::@ref DXEndpoint::Role "Role"::@ref
* DXEndpoint.Role::FEED "FEED").
* @see DXEndpoint::getInstance(Role)
* @throws std::invalid_argument
* @throws InvalidArgumentException
* @throws JavaException
* @throws GraalException
*/
Expand All @@ -533,7 +533,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared<DXEndpoint> {
*
* @param role The role of DXEndpoint instance
* @return The DXEndpoint instance
* @throws std::invalid_argument
* @throws InvalidArgumentException
* @throws JavaException
* @throws GraalException
*/
Expand All @@ -546,7 +546,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared<DXEndpoint> {
* Use Builder::build() to build an instance of DXEndpoint when all configuration properties were set.
*
* @return the created endpoint builder.
* @throws std::invalid_argument
* @throws InvalidArgumentException
* @throws JavaException
* @throws GraalException
*/
Expand All @@ -559,7 +559,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared<DXEndpoint> {
* @ref DXEndpoint::newBuilder() "newBuilder()"->@ref Builder::build() "build()"
*
* @return the created endpoint.
* @throws std::invalid_argument
* @throws InvalidArgumentException
* @throws JavaException
* @throws GraalException
*/
Expand All @@ -573,7 +573,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared<DXEndpoint> {
*
* @param role the role.
* @return the created endpoint.
* @throws std::invalid_argument
* @throws InvalidArgumentException
* @throws JavaException
* @throws GraalException
*/
Expand All @@ -594,15 +594,15 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared<DXEndpoint> {
* @return the state.
*
* @see DXEndpoint
* @throws std::invalid_argument
* @throws InvalidArgumentException
* @throws JavaException
* @throws GraalException
*/
State getState() const;

/**
* @return `true` if the endpoint is closed
* @throws std::invalid_argument
* @throws InvalidArgumentException
* @throws JavaException
* @throws GraalException
*/
Expand Down Expand Up @@ -658,7 +658,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared<DXEndpoint> {
* @param user The user name.
*
* @return this DXEndpoint.
* @throws std::invalid_argument
* @throws InvalidArgumentException
* @throws JavaException
* @throws GraalException
*/
Expand All @@ -672,7 +672,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared<DXEndpoint> {
* @param password The password.
*
* @return this DXEndpoint.
* @throws std::invalid_argument
* @throws InvalidArgumentException
* @throws JavaException
* @throws GraalException
*/
Expand Down Expand Up @@ -706,7 +706,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared<DXEndpoint> {
* @param address The data source address.
* @return this DXEndpoint.
*
* @throws std::invalid_argument
* @throws InvalidArgumentException
* @throws JavaException if something happened with the dxFeed API backend or if address string is malformed.
* @throws GraalException
*/
Expand All @@ -728,7 +728,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared<DXEndpoint> {
*
* [Javadoc.](https://docs.dxfeed.com/dxfeed/api/com/dxfeed/api/DXEndpoint.html#reconnect--)
*
* @throws std::invalid_argument
* @throws InvalidArgumentException
* @throws JavaException
* @throws GraalException
*/
Expand All @@ -744,7 +744,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared<DXEndpoint> {
*
* [Javadoc.](https://docs.dxfeed.com/dxfeed/api/com/dxfeed/api/DXEndpoint.html#disconnect--)
*
* @throws std::invalid_argument
* @throws InvalidArgumentException
* @throws JavaException
* @throws GraalException
*/
Expand All @@ -760,7 +760,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared<DXEndpoint> {
*
* [Javadoc.](https://docs.dxfeed.com/dxfeed/api/com/dxfeed/api/DXEndpoint.html#disconnectAndClear--)
*
* @throws std::invalid_argument
* @throws InvalidArgumentException
* @throws JavaException
* @throws GraalException
*/
Expand All @@ -775,7 +775,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared<DXEndpoint> {
*
* [Javadoc.](https://docs.dxfeed.com/dxfeed/api/com/dxfeed/api/DXEndpoint.html#close--)
*
* @throws std::invalid_argument
* @throws InvalidArgumentException
* @throws JavaException
* @throws GraalException
*/
Expand All @@ -792,7 +792,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared<DXEndpoint> {
*
* [Javadoc.](https://docs.dxfeed.com/dxfeed/api/com/dxfeed/api/DXEndpoint.html#awaitNotConnected--)
*
* @throws std::invalid_argument
* @throws InvalidArgumentException
* @throws JavaException
* @throws GraalException
*/
Expand All @@ -805,7 +805,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared<DXEndpoint> {
*
* [Javadoc.](https://docs.dxfeed.com/dxfeed/api/com/dxfeed/api/DXEndpoint.html#awaitProcessed--)
*
* @throws std::invalid_argument
* @throws InvalidArgumentException
* @throws JavaException
* @throws GraalException
*/
Expand All @@ -822,7 +822,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared<DXEndpoint> {
*
* [Javadoc.](https://docs.dxfeed.com/dxfeed/api/com/dxfeed/api/DXEndpoint.html#closeAndAwaitTermination--)
*
* @throws std::invalid_argument
* @throws InvalidArgumentException
* @throws JavaException
* @throws GraalException
*/
Expand All @@ -833,15 +833,15 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared<DXEndpoint> {

/**
* @return The feed that is associated with this endpoint.
* @throws std::invalid_argument
* @throws InvalidArgumentException
* @throws JavaException
* @throws GraalException
*/
std::shared_ptr<DXFeed> getFeed();

/**
* @return The publisher that is associated with this endpoint.
* @throws std::invalid_argument
* @throws InvalidArgumentException
* @throws JavaException
* @throws GraalException
*/
Expand All @@ -852,7 +852,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared<DXEndpoint> {
*
* Some methods that are not marked `noexcept` may throw exceptions:
*
* @throws std::invalid_argument if handle is invalid.
* @throws InvalidArgumentException if handle is invalid.
* @throws JavaException if something happened with the dxFeed API backend
* @throws GraalException if something happened with the GraalVM
*/
Expand Down Expand Up @@ -880,7 +880,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared<DXEndpoint> {
* or "dxpublisher.properties" for the Role::PUBLISHER role.
*
* Non thread-safe.
* @throws std::invalid_argument
* @throws InvalidArgumentException
* @throws JavaException
* @throws GraalException
*/
Expand All @@ -900,7 +900,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared<DXEndpoint> {
* @param name The endpoint's name
*
* @return `this` endpoint builder.
* @throws std::invalid_argument
* @throws InvalidArgumentException
* @throws JavaException
* @throws GraalException
*/
Expand All @@ -913,7 +913,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared<DXEndpoint> {
* @param role The endpoint's role
*
* @return `this` endpoint builder.
* @throws std::invalid_argument
* @throws InvalidArgumentException
* @throws JavaException
* @throws GraalException
*/
Expand All @@ -927,7 +927,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared<DXEndpoint> {
* @return `this` endpoint builder.
*
* @see ::supportsProperty(const std::string&)
* @throws std::invalid_argument
* @throws InvalidArgumentException
* @throws JavaException
* @throws GraalException
*/
Expand All @@ -941,7 +941,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared<DXEndpoint> {
* @return `this` endpoint builder.
*
* @see ::withProperty(const std::string&, const std::string&)
* @throws std::invalid_argument
* @throws InvalidArgumentException
* @throws JavaException
* @throws GraalException
*/
Expand All @@ -965,7 +965,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared<DXEndpoint> {
* @return `true` if the corresponding property key is supported.
*
* @see ::withProperty(const std::string&, const std::string&)
* @throws std::invalid_argument
* @throws InvalidArgumentException
* @throws JavaException
* @throws GraalException
*/
Expand All @@ -975,7 +975,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared<DXEndpoint> {
* Builds DXEndpoint instance.
*
* @return the created endpoint.
* @throws std::invalid_argument
* @throws InvalidArgumentException
* @throws JavaException
* @throws GraalException
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class DXFCPP_EXPORT IndexedEventSubscriptionSymbol {
* Releases the memory occupied by the dxFeed Graal SDK structure (recursively if necessary).
*
* @param graalNative The pointer to the dxFeed Graal SDK structure.
* @throws InvalidArgumentException
*/
static void freeGraal(void *graalNative);

Expand All @@ -65,7 +66,7 @@ class DXFCPP_EXPORT IndexedEventSubscriptionSymbol {
*
* @param graalNative The pointer to the dxFeed Graal SDK structure.
* @return The object of current type.
* @throws std::invalid_argument
* @throws InvalidArgumentException
*/
static IndexedEventSubscriptionSymbol fromGraal(void *graalNative);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class DXFCPP_EXPORT TimeSeriesSubscriptionSymbol final : public IndexedEventSubs
* Releases the memory occupied by the dxFeed Graal SDK structure (recursively if necessary).
*
* @param graalNative The pointer to the dxFeed Graal SDK structure.
* @throws InvalidArgumentException
*/
static void freeGraal(void *graalNative);

Expand All @@ -93,7 +94,7 @@ class DXFCPP_EXPORT TimeSeriesSubscriptionSymbol final : public IndexedEventSubs
*
* @param graalNative The pointer to the dxFeed Graal SDK structure.
* @return The object of current type.
* @throws std::invalid_argument
* @throws InvalidArgumentException
*/
static TimeSeriesSubscriptionSymbol fromGraal(void *graalNative);

Expand Down
3 changes: 2 additions & 1 deletion include/dxfeed_graal_cpp_api/api/osub/WildcardSymbol.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ struct DXFCPP_EXPORT WildcardSymbol final {
* Releases the memory occupied by the dxFeed Graal SDK structure (recursively if necessary).
*
* @param graalNative The pointer to the dxFeed Graal SDK structure.
* @throws InvalidArgumentException
*/
static void freeGraal(void *graalNative);

Expand All @@ -81,7 +82,7 @@ struct DXFCPP_EXPORT WildcardSymbol final {
*
* @param graalNative The pointer to the dxFeed Graal SDK structure.
* @return The object of current type.
* @throws std::invalid_argument
* @throws InvalidArgumentException
*/
static const WildcardSymbol &fromGraal(void *graalNative);

Expand Down
3 changes: 2 additions & 1 deletion include/dxfeed_graal_cpp_api/event/IndexedEventSource.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class DXFCPP_EXPORT IndexedEventSource {
* Releases the memory occupied by the dxFeed Graal SDK structure (recursively if necessary).
*
* @param graalNative The pointer to the dxFeed Graal SDK structure.
* @throws InvalidArgumentException
*/
static void freeGraal(void *graalNative);

Expand All @@ -49,7 +50,7 @@ class DXFCPP_EXPORT IndexedEventSource {
*
* @param graalNative The pointer to the dxFeed Graal SDK structure.
* @return The object of current type.
* @throws std::invalid_argument
* @throws InvalidArgumentException
*/
static IndexedEventSource fromGraal(void *graalNative);

Expand Down
10 changes: 7 additions & 3 deletions include/dxfeed_graal_cpp_api/event/candle/Candle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ DXFCXX_DISABLE_MSC_WARNINGS_PUSH(4251)
#include <utility>

#include "../../internal/Common.hpp"

#include "../../exceptions/InvalidArgumentException.hpp"

#include "../EventType.hpp"
#include "../EventTypeEnum.hpp"
#include "../IndexedEventSource.hpp"
Expand Down Expand Up @@ -126,7 +129,7 @@ class DXFCPP_EXPORT Candle final : public EventTypeWithSymbol<CandleSymbol>,
*
* @param graalNative The pointer to the dxFeed Graal SDK structure.
* @return The object of current type.
* @throws std::invalid_argument
* @throws InvalidArgumentException
*/
static Ptr fromGraal(void *graalNative);

Expand All @@ -143,6 +146,7 @@ class DXFCPP_EXPORT Candle final : public EventTypeWithSymbol<CandleSymbol>,
* Releases the memory occupied by the dxFeed Graal SDK structure (recursively if necessary).
*
* @param graalNative The pointer to the dxFeed Graal SDK structure.
* @throws InvalidArgumentException
*/
static void freeGraal(void *graalNative);

Expand Down Expand Up @@ -343,13 +347,13 @@ class DXFCPP_EXPORT Candle final : public EventTypeWithSymbol<CandleSymbol>,
*
* @param sequence the sequence.
* @see Candle::getSequence()
* @throws std::invalid_argument if sequence is below zero or above ::MAX_SEQUENCE.
* @throws InvalidArgumentException if sequence is below zero or above ::MAX_SEQUENCE.
*/
void setSequence(std::int32_t sequence) {
assert(sequence >= 0 && static_cast<std::uint32_t>(sequence) <= MAX_SEQUENCE);

if (sequence < 0 || static_cast<std::uint32_t>(sequence) > MAX_SEQUENCE) {
throw std::invalid_argument("Invalid value for argument `sequence`: " + std::to_string(sequence));
throw InvalidArgumentException("Invalid value for argument `sequence`: " + std::to_string(sequence));
}

data_.index = orOp(andOp(data_.index, ~MAX_SEQUENCE), sequence);
Expand Down
Loading