From f6328c560e065ea54e66b36dec145392a5409bed Mon Sep 17 00:00:00 2001 From: Anatoly Kalin Date: Mon, 22 Jul 2024 13:38:08 +0300 Subject: [PATCH 1/7] [MDAPI-113] [C++][Tools] Tools should report invalid event type LatencyTest: refactor --- tools/Tools/src/LatencyTest/LatencyTestTool.hpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/tools/Tools/src/LatencyTest/LatencyTestTool.hpp b/tools/Tools/src/LatencyTest/LatencyTestTool.hpp index e9438d37b..4d6551e8c 100644 --- a/tools/Tools/src/LatencyTest/LatencyTestTool.hpp +++ b/tools/Tools/src/LatencyTest/LatencyTestTool.hpp @@ -44,8 +44,8 @@ struct LatencyTest { [[nodiscard]] static std::string prepareHelp(std::size_t namePadding, std::size_t nameFieldSize /* padding + name + padding */, std::size_t) noexcept { - return fmt::format("{:{}}{:<{}}{:{}}{}\n", "", namePadding, getFullName(), - nameFieldSize - 2 * namePadding, "", namePadding, SHORT_DESCRIPTION); + return fmt::format("{:{}}{:<{}}{:{}}{}\n", "", namePadding, getFullName(), nameFieldSize - 2 * namePadding, "", + namePadding, SHORT_DESCRIPTION); } struct Diagnostic final { @@ -320,16 +320,21 @@ struct LatencyTest { intervalIsParsed = true; index = parseResult.nextIndex; } else { - if (!forceStream && (forceStream = ForceStreamArg::parse(args, index).result)) { - index++; - continue; + if (!forceStream) { + forceStream = ForceStreamArg::parse(args, index).result; + + if (forceStream) { + index++; + continue; + } } index++; } } - return ParseResult::ok({parsedAddress.result, parsedTypes.result, parsedSymbols.result, properties, forceStream, interval.value_or(2)}); + return ParseResult::ok({parsedAddress.result, parsedTypes.result, parsedSymbols.result, properties, + forceStream, interval.value_or(2)}); } }; From a5ef177b941bd9ce51d07d5e2241f38fd0eb5240 Mon Sep 17 00:00:00 2001 From: ttldtor Date: Wed, 24 Jul 2024 14:08:49 +0300 Subject: [PATCH 2/7] [MDAPI-113] [C++][Tools] Tools should report invalid event type dxfcpp::RuntimeException --- CMakeLists.txt | 1 + include/dxfeed_graal_cpp_api/api.hpp | 1 + .../exceptions/GraalException.hpp | 11 +-- .../exceptions/JavaException.hpp | 19 ++--- .../exceptions/RuntimeException.hpp | 41 ++++++++++ samples/cpp/ConvertTapeFile/src/main.cpp | 8 +- samples/cpp/DxFeedConnect/src/main.cpp | 8 +- samples/cpp/DxFeedFileParser/src/main.cpp | 8 +- samples/cpp/DxFeedIpfConnect/src/main.cpp | 8 +- samples/cpp/DxFeedLiveIpfSample/src/main.cpp | 8 +- samples/cpp/DxFeedSample/src/main.cpp | 8 +- samples/cpp/FetchDailyCandles/src/main.cpp | 8 +- samples/cpp/OnDemandSample/src/main.cpp | 8 +- samples/cpp/PrintQuoteEvents/src/main.cpp | 8 +- samples/cpp/PublishProfiles/src/main.cpp | 8 +- samples/cpp/ScheduleSample/src/main.cpp | 8 +- samples/cpp/WriteTapeFile/src/main.cpp | 8 +- src/exceptions/GraalException.cpp | 7 +- src/exceptions/JavaException.cpp | 68 ++-------------- src/exceptions/RuntimeException.cpp | 81 +++++++++++++++++++ tools/Tools/src/Connect/ConnectTool.hpp | 8 +- tools/Tools/src/Dump/DumpTool.hpp | 8 +- .../Tools/src/LatencyTest/LatencyTestTool.hpp | 9 +-- tools/Tools/src/PerfTest/PerfTestTool.hpp | 8 +- tools/Tools/src/main.cpp | 16 +--- 25 files changed, 178 insertions(+), 196 deletions(-) create mode 100644 include/dxfeed_graal_cpp_api/exceptions/RuntimeException.hpp create mode 100644 src/exceptions/RuntimeException.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 449377175..a4f9563e8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -199,6 +199,7 @@ set(dxFeedGraalCxxApi_InternalUtilsDebug_Sources ) set(dxFeedGraalCxxApi_Exceptions_Sources + src/exceptions/RuntimeException.cpp src/exceptions/GraalException.cpp src/exceptions/JavaException.cpp ) diff --git a/include/dxfeed_graal_cpp_api/api.hpp b/include/dxfeed_graal_cpp_api/api.hpp index 3e63c1164..eaf5aafb5 100644 --- a/include/dxfeed_graal_cpp_api/api.hpp +++ b/include/dxfeed_graal_cpp_api/api.hpp @@ -52,6 +52,7 @@ DXFCXX_DISABLE_MSC_WARNINGS_PUSH(4251 4996) #include "isolated/Isolated.hpp" +#include "exceptions/RuntimeException.hpp" #include "exceptions/JavaException.hpp" #include "exceptions/GraalException.hpp" diff --git a/include/dxfeed_graal_cpp_api/exceptions/GraalException.hpp b/include/dxfeed_graal_cpp_api/exceptions/GraalException.hpp index 67269bbe6..44424544f 100644 --- a/include/dxfeed_graal_cpp_api/exceptions/GraalException.hpp +++ b/include/dxfeed_graal_cpp_api/exceptions/GraalException.hpp @@ -9,6 +9,8 @@ DXFCXX_DISABLE_MSC_WARNINGS_PUSH(4251 4275) #include "../internal/CEntryPointErrors.hpp" +#include "RuntimeException.hpp" + #include #include @@ -17,7 +19,7 @@ DXFCPP_BEGIN_NAMESPACE /** * The wrapper over CEntryPointErrorsEnum, the error code returned by GraalVM. */ -struct DXFCPP_EXPORT GraalException : public std::runtime_error { +struct DXFCPP_EXPORT GraalException : RuntimeException { /** * Constructs an exception. * @@ -25,11 +27,6 @@ struct DXFCPP_EXPORT GraalException : public std::runtime_error { */ GraalException(CEntryPointErrorsEnum entryPointErrorsEnum); - /** - * @return dxFeed Graal CXX API stack trace - */ - const std::string& getStackTrace() const&; - private: static inline std::string createMessage(CEntryPointErrorsEnum entryPointErrorsEnum) { auto result = CEntryPointErrorsEnumToStr(entryPointErrorsEnum); @@ -41,8 +38,6 @@ struct DXFCPP_EXPORT GraalException : public std::runtime_error { return result; } - - std::string stackTrace_; }; DXFCPP_END_NAMESPACE diff --git a/include/dxfeed_graal_cpp_api/exceptions/JavaException.hpp b/include/dxfeed_graal_cpp_api/exceptions/JavaException.hpp index b27c9f926..b7648f676 100644 --- a/include/dxfeed_graal_cpp_api/exceptions/JavaException.hpp +++ b/include/dxfeed_graal_cpp_api/exceptions/JavaException.hpp @@ -5,8 +5,12 @@ #include "../internal/Conf.hpp" +#include "../internal/Common.hpp" + DXFCXX_DISABLE_MSC_WARNINGS_PUSH(4251 4275) +#include "RuntimeException.hpp" + #include #include #include @@ -17,7 +21,7 @@ DXFCPP_BEGIN_NAMESPACE /** * A wrapper over the interceptable Java exceptions thrown by the dxFeed Native Graal SDK */ -struct DXFCPP_EXPORT JavaException : public std::runtime_error { +struct DXFCPP_EXPORT JavaException : RuntimeException { /** * Creates an exception using Java message, className and stack trace. Also uses current stack trace. * @@ -25,7 +29,8 @@ struct DXFCPP_EXPORT JavaException : public std::runtime_error { * @param className Java class name. * @param stackTrace Java stack trace. */ - JavaException(const std::string &message, const std::string &className, std::string stackTrace); + JavaException(const StringLikeWrapper &message, const StringLikeWrapper &className, + const StringLikeWrapper &stackTrace); /** * Creates an exception using native (GraalVM) Java exception handle @@ -33,7 +38,7 @@ struct DXFCPP_EXPORT JavaException : public std::runtime_error { * @param exceptionHandle The native Java exception handle. * @return An exception. */ - static JavaException create(void* exceptionHandle); + static JavaException create(void *exceptionHandle); /// Throws a JavaException if it exists (i.e. intercepted by Graal SDK) static void throwIfJavaThreadExceptionExists(); @@ -87,14 +92,6 @@ struct DXFCPP_EXPORT JavaException : public std::runtime_error { return v; } - - /** - * @return dxFeed Graal CXX API stack trace + Java (GraalVM) exception's stack trace. - */ - const std::string &getStackTrace() const &; - - private: - std::string stackTrace_; }; DXFCPP_END_NAMESPACE diff --git a/include/dxfeed_graal_cpp_api/exceptions/RuntimeException.hpp b/include/dxfeed_graal_cpp_api/exceptions/RuntimeException.hpp new file mode 100644 index 000000000..4c7bdb454 --- /dev/null +++ b/include/dxfeed_graal_cpp_api/exceptions/RuntimeException.hpp @@ -0,0 +1,41 @@ +// Copyright (c) 2024 Devexperts LLC. +// SPDX-License-Identifier: MPL-2.0 + +#pragma once + +#include "../internal/Conf.hpp" + +#include "../internal/Common.hpp" + +DXFCXX_DISABLE_MSC_WARNINGS_PUSH(4251 4275) + +#include +#include + +DXFCPP_BEGIN_NAMESPACE + +/** + * A runtime axception with stacktrace + */ +struct DXFCPP_EXPORT RuntimeException : std::runtime_error { + /** + * Constructs a runtime exception. + * + * @param message The exception's message. + * @param additionalStackTrace The additional stacktrace that will be concatenated with current stacktrace. + */ + explicit RuntimeException(const StringLikeWrapper& message, const StringLikeWrapper& additionalStackTrace = ""); + + /** + * @return The current stacktrace + the additional stacktrace if present. + */ + const std::string& getStackTrace() const &; +private: + std::string stackTrace_; +}; + +DXFCPP_END_NAMESPACE + +DXFCPP_EXPORT std::ostream &operator<<(std::ostream &os, const dxfcpp::RuntimeException &e); + +DXFCXX_DISABLE_MSC_WARNINGS_POP() \ No newline at end of file diff --git a/samples/cpp/ConvertTapeFile/src/main.cpp b/samples/cpp/ConvertTapeFile/src/main.cpp index 61108307a..d8afbf358 100644 --- a/samples/cpp/ConvertTapeFile/src/main.cpp +++ b/samples/cpp/ConvertTapeFile/src/main.cpp @@ -70,12 +70,8 @@ int main(int argc, char *argv[]) { // Wait until all data is processed and written, and then gracefully close output endpoint. outputEndpoint->awaitProcessed(); outputEndpoint->closeAndAwaitTermination(); - } catch (const JavaException &e) { - std::cerr << e.what() << '\n'; - std::cerr << e.getStackTrace() << '\n'; - } catch (const GraalException &e) { - std::cerr << e.what() << '\n'; - std::cerr << e.getStackTrace() << '\n'; + } catch (const RuntimeException &e) { + std::cerr << e << '\n'; } return 0; diff --git a/samples/cpp/DxFeedConnect/src/main.cpp b/samples/cpp/DxFeedConnect/src/main.cpp index 1a6f93573..e42a6ab79 100644 --- a/samples/cpp/DxFeedConnect/src/main.cpp +++ b/samples/cpp/DxFeedConnect/src/main.cpp @@ -91,12 +91,8 @@ int main(int argc, char *argv[]) { } std::cin.get(); - } catch (const JavaException &e) { - std::cerr << e.what() << '\n'; - std::cerr << e.getStackTrace() << '\n'; - } catch (const GraalException &e) { - std::cerr << e.what() << '\n'; - std::cerr << e.getStackTrace() << '\n'; + } catch (const RuntimeException &e) { + std::cerr << e << '\n'; } return 0; diff --git a/samples/cpp/DxFeedFileParser/src/main.cpp b/samples/cpp/DxFeedFileParser/src/main.cpp index da767f198..682bb7ab7 100644 --- a/samples/cpp/DxFeedFileParser/src/main.cpp +++ b/samples/cpp/DxFeedFileParser/src/main.cpp @@ -68,12 +68,8 @@ int main(int argc, char *argv[]) { // Close endpoint when we're done. // This method will gracefully close endpoint, waiting while data processing completes. endpoint->closeAndAwaitTermination(); - } catch (const JavaException &e) { - std::cerr << e.what() << '\n'; - std::cerr << e.getStackTrace() << '\n'; - } catch (const GraalException &e) { - std::cerr << e.what() << '\n'; - std::cerr << e.getStackTrace() << '\n'; + } catch (const RuntimeException &e) { + std::cerr << e << '\n'; } return 0; diff --git a/samples/cpp/DxFeedIpfConnect/src/main.cpp b/samples/cpp/DxFeedIpfConnect/src/main.cpp index d516252ff..f54671d37 100644 --- a/samples/cpp/DxFeedIpfConnect/src/main.cpp +++ b/samples/cpp/DxFeedIpfConnect/src/main.cpp @@ -79,11 +79,7 @@ int main(int argc, char *argv[]) { sub->addSymbols(getSymbols(ipfFile)); std::this_thread::sleep_for(std::chrono::days(365)); - } catch (const JavaException &e) { - std::cerr << e.what() << '\n'; - std::cerr << e.getStackTrace() << '\n'; - } catch (const GraalException &e) { - std::cerr << e.what() << '\n'; - std::cerr << e.getStackTrace() << '\n'; + } catch (const RuntimeException &e) { + std::cerr << e << '\n'; } } diff --git a/samples/cpp/DxFeedLiveIpfSample/src/main.cpp b/samples/cpp/DxFeedLiveIpfSample/src/main.cpp index 29fdaa49a..907111638 100644 --- a/samples/cpp/DxFeedLiveIpfSample/src/main.cpp +++ b/samples/cpp/DxFeedLiveIpfSample/src/main.cpp @@ -102,11 +102,7 @@ int main(int argc, char *argv[]) { std::this_thread::sleep_for(std::chrono::days(365)); connection->close(); - } catch (const JavaException &e) { - std::cerr << e.what() << '\n'; - std::cerr << e.getStackTrace() << '\n'; - } catch (const GraalException &e) { - std::cerr << e.what() << '\n'; - std::cerr << e.getStackTrace() << '\n'; + } catch (const RuntimeException &e) { + std::cerr << e << '\n'; } } \ No newline at end of file diff --git a/samples/cpp/DxFeedSample/src/main.cpp b/samples/cpp/DxFeedSample/src/main.cpp index 0e82bcdbe..c50ec59b4 100644 --- a/samples/cpp/DxFeedSample/src/main.cpp +++ b/samples/cpp/DxFeedSample/src/main.cpp @@ -75,11 +75,7 @@ DxFeedSample testQuoteAndTradeListener(symbol); std::cin.get(); - } catch (const JavaException &e) { - std::cerr << e.what() << '\n'; - std::cerr << e.getStackTrace() << '\n'; - } catch (const GraalException &e) { - std::cerr << e.what() << '\n'; - std::cerr << e.getStackTrace() << '\n'; + } catch (const RuntimeException &e) { + std::cerr << e << '\n'; } } diff --git a/samples/cpp/FetchDailyCandles/src/main.cpp b/samples/cpp/FetchDailyCandles/src/main.cpp index a2d653922..8fb934ee1 100644 --- a/samples/cpp/FetchDailyCandles/src/main.cpp +++ b/samples/cpp/FetchDailyCandles/src/main.cpp @@ -46,11 +46,7 @@ FetchDailyCandles std::cout << "Fetching last " << DAYS << " days of candles for " << baseSymbol << "\n"; fetchAndPrint(candleSymbol, toTime, fromTime); - } catch (const JavaException &e) { - std::cerr << e.what() << '\n'; - std::cerr << e.getStackTrace() << '\n'; - } catch (const GraalException &e) { - std::cerr << e.what() << '\n'; - std::cerr << e.getStackTrace() << '\n'; + } catch (const RuntimeException &e) { + std::cerr << e << '\n'; } } diff --git a/samples/cpp/OnDemandSample/src/main.cpp b/samples/cpp/OnDemandSample/src/main.cpp index 1071fd8ee..23104eb72 100644 --- a/samples/cpp/OnDemandSample/src/main.cpp +++ b/samples/cpp/OnDemandSample/src/main.cpp @@ -53,11 +53,7 @@ int main(int /* argc */, char ** /* argv */) { // close endpoint completely to release resources and shutdown GraalVM onDemand->getEndpoint()->closeAndAwaitTermination(); - } catch (const JavaException &e) { - std::cerr << e.what() << '\n'; - std::cerr << e.getStackTrace() << '\n'; - } catch (const GraalException &e) { - std::cerr << e.what() << '\n'; - std::cerr << e.getStackTrace() << '\n'; + } catch (const RuntimeException &e) { + std::cerr << e << '\n'; } } diff --git a/samples/cpp/PrintQuoteEvents/src/main.cpp b/samples/cpp/PrintQuoteEvents/src/main.cpp index 5995508fc..18091fb7b 100644 --- a/samples/cpp/PrintQuoteEvents/src/main.cpp +++ b/samples/cpp/PrintQuoteEvents/src/main.cpp @@ -34,11 +34,7 @@ int main(int argc, char *argv[]) { subscription->addSymbols(symbol); std::cin.get(); - } catch (const JavaException &e) { - std::cerr << e.what() << '\n'; - std::cerr << e.getStackTrace() << '\n'; - } catch (const GraalException &e) { - std::cerr << e.what() << '\n'; - std::cerr << e.getStackTrace() << '\n'; + } catch (const RuntimeException &e) { + std::cerr << e << '\n'; } } diff --git a/samples/cpp/PublishProfiles/src/main.cpp b/samples/cpp/PublishProfiles/src/main.cpp index c3e36c165..39d9613e2 100644 --- a/samples/cpp/PublishProfiles/src/main.cpp +++ b/samples/cpp/PublishProfiles/src/main.cpp @@ -53,12 +53,8 @@ int main(int argc, char *argv[]) { })); std::cin.get(); - } catch (const JavaException &e) { - std::cerr << e.what() << '\n'; - std::cerr << e.getStackTrace() << '\n'; - } catch (const GraalException &e) { - std::cerr << e.what() << '\n'; - std::cerr << e.getStackTrace() << '\n'; + } catch (const RuntimeException &e) { + std::cerr << e << '\n'; } return 0; diff --git a/samples/cpp/ScheduleSample/src/main.cpp b/samples/cpp/ScheduleSample/src/main.cpp index b49e51e67..f60b6b268 100644 --- a/samples/cpp/ScheduleSample/src/main.cpp +++ b/samples/cpp/ScheduleSample/src/main.cpp @@ -225,11 +225,7 @@ int main(int argc, char *argv[]) { printCurrentSession(profile, time); printNextTradingSession(profile, time); printNearestTradingSession(profile, time); - } catch (const JavaException &e) { - std::cerr << e.what() << '\n'; - std::cerr << e.getStackTrace() << '\n'; - } catch (const GraalException &e) { - std::cerr << e.what() << '\n'; - std::cerr << e.getStackTrace() << '\n'; + } catch (const RuntimeException &e) { + std::cerr << e << '\n'; } } \ No newline at end of file diff --git a/samples/cpp/WriteTapeFile/src/main.cpp b/samples/cpp/WriteTapeFile/src/main.cpp index 567bf34d1..da277b92a 100644 --- a/samples/cpp/WriteTapeFile/src/main.cpp +++ b/samples/cpp/WriteTapeFile/src/main.cpp @@ -33,12 +33,8 @@ int main() { // Wait until all data is written, close, and wait until it closes. endpoint->awaitProcessed(); endpoint->closeAndAwaitTermination(); - } catch (const JavaException &e) { - std::cerr << e.what() << '\n'; - std::cerr << e.getStackTrace() << '\n'; - } catch (const GraalException &e) { - std::cerr << e.what() << '\n'; - std::cerr << e.getStackTrace() << '\n'; + } catch (const RuntimeException &e) { + std::cerr << e << '\n'; } return 0; diff --git a/src/exceptions/GraalException.cpp b/src/exceptions/GraalException.cpp index c3576ae42..9a1ee17cf 100644 --- a/src/exceptions/GraalException.cpp +++ b/src/exceptions/GraalException.cpp @@ -13,12 +13,7 @@ DXFCPP_BEGIN_NAMESPACE std::string stackTraceToString(const boost::stacktrace::stacktrace &stacktrace); GraalException::GraalException(CEntryPointErrorsEnum entryPointErrorsEnum) - : std::runtime_error(createMessage(entryPointErrorsEnum)), - stackTrace_{stackTraceToString(boost::stacktrace::stacktrace())} { -} - -const std::string &GraalException::getStackTrace() const & { - return stackTrace_; + : RuntimeException(createMessage(entryPointErrorsEnum)) { } DXFCPP_END_NAMESPACE \ No newline at end of file diff --git a/src/exceptions/JavaException.cpp b/src/exceptions/JavaException.cpp index b3ee9a5a8..9f489c679 100644 --- a/src/exceptions/JavaException.cpp +++ b/src/exceptions/JavaException.cpp @@ -10,6 +10,8 @@ DXFCPP_BEGIN_NAMESPACE +std::string stackTraceToString(const boost::stacktrace::stacktrace &stacktrace); + void JavaException::throwIfJavaThreadExceptionExists() { dxfg_exception_t *exception = runIsolatedThrow([](auto threadHandle) { return dxfg_get_and_clear_thread_exception_t(static_cast(threadHandle)); @@ -36,64 +38,10 @@ void JavaException::throwException() { }); } -std::string stackTraceToString(const boost::stacktrace::stacktrace &stacktrace) { - std::string result; - - for (auto &&frame : stacktrace) { - result += "\tat "; - auto frameString = boost::stacktrace::to_string(frame); - - if (frameString.empty()) { - result += "\n"; - - continue; - } - - std::string what; - std::size_t whereStart = 0; - - auto foundIn = frameString.find(" in "); - - if (foundIn != std::string::npos) { - what = frameString.substr(0, foundIn); - whereStart = foundIn + 4; - } else { - auto foundAt = frameString.find(" at "); - - if (foundAt != std::string::npos) { - what = frameString.substr(0, foundAt); - whereStart = foundIn + 4; - } else { - whereStart = frameString.size(); - } - } - - if (whereStart == frameString.size()) { - what = frameString; - - result += what + "\n"; - - continue; - } - - auto foundLastSep = frameString.find_last_of("\\/"); - std::string where; - - if (foundLastSep != std::string::npos && foundLastSep < frameString.size() - 1) { - where = frameString.substr(foundLastSep + 1); - } else { - where = frameString.substr(whereStart); - } - - result += fmt::format("{}({})\n", what, where); - } - - return result; -} - -JavaException::JavaException(const std::string &message, const std::string &className, std::string stackTrace) - : std::runtime_error(fmt::format("Java exception of type '{}' was thrown. {}", className, message)), - stackTrace_{std::move(stackTrace) + "\n" + stackTraceToString(boost::stacktrace::stacktrace())} { +JavaException::JavaException(const StringLikeWrapper &message, const StringLikeWrapper &className, + const StringLikeWrapper &stackTrace) + : RuntimeException(fmt::format("Java exception of type '{}' was thrown. {}", className.c_str(), message.c_str()), + stackTrace) { } JavaException JavaException::create(void *exceptionHandle) { @@ -106,8 +54,4 @@ JavaException JavaException::create(void *exceptionHandle) { return {toString(exception->message), toString(exception->class_name), toString(exception->print_stack_trace)}; } -const std::string &JavaException::getStackTrace() const & { - return stackTrace_; -} - DXFCPP_END_NAMESPACE \ No newline at end of file diff --git a/src/exceptions/RuntimeException.cpp b/src/exceptions/RuntimeException.cpp new file mode 100644 index 000000000..0e6ae776a --- /dev/null +++ b/src/exceptions/RuntimeException.cpp @@ -0,0 +1,81 @@ +// Copyright (c) 2024 Devexperts LLC. +// SPDX-License-Identifier: MPL-2.0 + +#include + +#include +#include + +DXFCPP_BEGIN_NAMESPACE + +std::string stackTraceToString(const boost::stacktrace::stacktrace &stacktrace) { + std::string result; + + for (auto &&frame : stacktrace) { + result += "\tat "; + auto frameString = boost::stacktrace::to_string(frame); + + if (frameString.empty()) { + result += "\n"; + + continue; + } + + std::string what; + std::size_t whereStart = 0; + + auto foundIn = frameString.find(" in "); + + if (foundIn != std::string::npos) { + what = frameString.substr(0, foundIn); + whereStart = foundIn + 4; + } else { + auto foundAt = frameString.find(" at "); + + if (foundAt != std::string::npos) { + what = frameString.substr(0, foundAt); + whereStart = foundIn + 4; + } else { + whereStart = frameString.size(); + } + } + + if (whereStart == frameString.size()) { + what = frameString; + + result += what + "\n"; + + continue; + } + + auto foundLastSep = frameString.find_last_of("\\/"); + std::string where; + + if (foundLastSep != std::string::npos && foundLastSep < frameString.size() - 1) { + where = frameString.substr(foundLastSep + 1); + } else { + where = frameString.substr(whereStart); + } + + result += fmt::format("{}({})\n", what, where); + } + + return result; +} + +RuntimeException::RuntimeException(const StringLikeWrapper &message, const StringLikeWrapper &additionalStackTrace) + : runtime_error(message.c_str()), + stackTrace_(additionalStackTrace.empty() ? stackTraceToString(boost::stacktrace::stacktrace()) + : fmt::format("{}\n{}", additionalStackTrace.c_str(), + stackTraceToString(boost::stacktrace::stacktrace()))) { +} + +const std::string &RuntimeException::getStackTrace() const & { + return stackTrace_; +} + +DXFCPP_END_NAMESPACE + +std::ostream &operator<<(std::ostream &os, const dxfcpp::RuntimeException &e) { + return os << fmt::format("{}\n{}", e.what(), e.getStackTrace()); +} diff --git a/tools/Tools/src/Connect/ConnectTool.hpp b/tools/Tools/src/Connect/ConnectTool.hpp index 9b6905a14..00dbc0af6 100644 --- a/tools/Tools/src/Connect/ConnectTool.hpp +++ b/tools/Tools/src/Connect/ConnectTool.hpp @@ -209,12 +209,8 @@ struct ConnectTool { sub->addSymbols(symbols); endpoint->connect(args.address); std::this_thread::sleep_for(std::chrono::days(365)); - } catch (const JavaException &e) { - std::cerr << e.what() << '\n'; - std::cerr << e.getStackTrace() << '\n'; - } catch (const GraalException &e) { - std::cerr << e.what() << '\n'; - std::cerr << e.getStackTrace() << '\n'; + } catch (const RuntimeException &e) { + std::cerr << e << '\n'; } } }; diff --git a/tools/Tools/src/Dump/DumpTool.hpp b/tools/Tools/src/Dump/DumpTool.hpp index 600dd428b..088da526f 100644 --- a/tools/Tools/src/Dump/DumpTool.hpp +++ b/tools/Tools/src/Dump/DumpTool.hpp @@ -184,12 +184,8 @@ struct DumpTool { outputEndpoint.value()->awaitProcessed(); outputEndpoint.value()->closeAndAwaitTermination(); } - } catch (const JavaException &e) { - std::cerr << e.what() << '\n'; - std::cerr << e.getStackTrace() << '\n'; - } catch (const GraalException &e) { - std::cerr << e.what() << '\n'; - std::cerr << e.getStackTrace() << '\n'; + } catch (const RuntimeException &e) { + std::cerr << e << '\n'; } } }; diff --git a/tools/Tools/src/LatencyTest/LatencyTestTool.hpp b/tools/Tools/src/LatencyTest/LatencyTestTool.hpp index 4d6551e8c..a45097f12 100644 --- a/tools/Tools/src/LatencyTest/LatencyTestTool.hpp +++ b/tools/Tools/src/LatencyTest/LatencyTestTool.hpp @@ -340,7 +340,6 @@ struct LatencyTest { static void run(const Args &args) noexcept { try { - using namespace std::literals; auto parsedProperties = CmdArgsUtils::parseProperties(args.properties); @@ -368,12 +367,8 @@ struct LatencyTest { endpoint->connect(args.address); endpoint->awaitNotConnected(); endpoint->closeAndAwaitTermination(); - } catch (const JavaException &e) { - std::cerr << e.what() << '\n'; - std::cerr << e.getStackTrace() << '\n'; - } catch (const GraalException &e) { - std::cerr << e.what() << '\n'; - std::cerr << e.getStackTrace() << '\n'; + } catch (const RuntimeException &e) { + std::cerr << e << '\n'; } } }; diff --git a/tools/Tools/src/PerfTest/PerfTestTool.hpp b/tools/Tools/src/PerfTest/PerfTestTool.hpp index e3af5bd8a..dcbe28a5b 100644 --- a/tools/Tools/src/PerfTest/PerfTestTool.hpp +++ b/tools/Tools/src/PerfTest/PerfTestTool.hpp @@ -271,12 +271,8 @@ struct PerfTestTool { endpoint->closeAndAwaitTermination(); std::cout << hash << std::endl; - } catch (const JavaException &e) { - std::cerr << e.what() << '\n'; - std::cerr << e.getStackTrace() << '\n'; - } catch (const GraalException &e) { - std::cerr << e.what() << '\n'; - std::cerr << e.getStackTrace() << '\n'; + } catch (const RuntimeException &e) { + std::cerr << e << '\n'; } } }; diff --git a/tools/Tools/src/main.cpp b/tools/Tools/src/main.cpp index 70661a07c..75f9920e0 100644 --- a/tools/Tools/src/main.cpp +++ b/tools/Tools/src/main.cpp @@ -83,12 +83,8 @@ int main(int argc, char *argv[]) { std::cout << tools::Tools::getName() << "\n"; T::run(parseResult.result); - } catch (const JavaException &e) { - std::cerr << e.what() << '\n'; - std::cerr << e.getStackTrace() << '\n'; - } catch (const GraalException &e) { - std::cerr << e.what() << '\n'; - std::cerr << e.getStackTrace() << '\n'; + } catch (const RuntimeException &e) { + std::cerr << e << '\n'; } }, tool); @@ -97,12 +93,8 @@ int main(int argc, char *argv[]) { } std::cout << usage << "\n"; - } catch (const JavaException &e) { - std::cerr << e.what() << '\n'; - std::cerr << e.getStackTrace() << '\n'; - } catch (const GraalException &e) { - std::cerr << e.what() << '\n'; - std::cerr << e.getStackTrace() << '\n'; + } catch (const RuntimeException &e) { + std::cerr << e << '\n'; } catch (const std::runtime_error &e) { std::cerr << e.what() << '\n'; } catch (...) { From 360475b41683c6fd3410b6bc1c40d52fd3b751e5 Mon Sep 17 00:00:00 2001 From: ttldtor Date: Wed, 24 Jul 2024 16:52:02 +0300 Subject: [PATCH 3/7] [MDAPI-113] [C++][Tools] Tools should report invalid event type dxfcpp::InvalidArgumentException --- CMakeLists.txt | 1 + include/dxfeed_graal_cpp_api/api.hpp | 1 + .../dxfeed_graal_cpp_api/api/DXEndpoint.hpp | 58 +++---- .../osub/IndexedEventSubscriptionSymbol.hpp | 3 +- .../api/osub/TimeSeriesSubscriptionSymbol.hpp | 3 +- .../api/osub/WildcardSymbol.hpp | 3 +- .../event/IndexedEventSource.hpp | 3 +- .../event/candle/Candle.hpp | 10 +- .../event/candle/CandleAlignment.hpp | 9 +- .../event/candle/CandlePeriod.hpp | 2 + .../event/candle/CandlePrice.hpp | 20 +-- .../event/candle/CandlePriceLevel.hpp | 5 +- .../event/candle/CandleSession.hpp | 17 +-- .../event/candle/CandleSymbol.hpp | 3 +- .../event/candle/CandleType.hpp | 18 +-- .../event/market/AnalyticOrder.hpp | 3 +- .../event/market/OptionSale.hpp | 6 +- .../event/market/Order.hpp | 3 +- .../event/market/OrderBase.hpp | 6 +- .../event/market/OrderSource.hpp | 8 +- .../event/market/OtcMarketsOrder.hpp | 3 +- .../event/market/Profile.hpp | 3 +- .../event/market/Quote.hpp | 6 +- .../event/market/SpreadOrder.hpp | 3 +- .../event/market/Summary.hpp | 3 +- .../event/market/TimeAndSale.hpp | 6 +- .../event/market/Trade.hpp | 3 +- .../event/market/TradeBase.hpp | 3 +- .../event/market/TradeETH.hpp | 3 +- .../event/misc/Message.hpp | 3 +- .../event/option/Greeks.hpp | 6 +- .../event/option/Series.hpp | 6 +- .../event/option/TheoPrice.hpp | 6 +- .../event/option/Underlying.hpp | 6 +- .../exceptions/InvalidArgumentException.hpp | 28 ++++ .../dxfeed_graal_cpp_api/internal/Common.hpp | 42 ++--- .../internal/TimeFormat.hpp | 2 +- .../ipf/InstrumentProfile.hpp | 2 +- .../isolated/api/IsolatedDXEndpoint.hpp | 44 +++--- .../api/IsolatedDXFeedSubscription.hpp | 34 ++--- .../isolated/api/IsolatedDXPublisher.hpp | 4 +- ...latedDXPublisherObservableSubscription.hpp | 10 +- ...edObservableSubscriptionChangeListener.hpp | 2 +- .../isolated/internal/IsolatedString.hpp | 4 +- .../isolated/promise/IsolatedPromise.hpp | 22 +-- .../symbols/StringSymbol.hpp | 3 +- .../symbols/SymbolWrapper.hpp | 4 +- src/api/DXEndpoint.cpp | 2 +- .../osub/IndexedEventSubscriptionSymbol.cpp | 2 +- src/api/osub/TimeSeriesSubscriptionSymbol.cpp | 2 +- src/event/EventMapper.cpp | 18 +-- src/event/candle/Candle.cpp | 6 +- src/event/market/AnalyticOrder.cpp | 6 +- src/event/market/OptionSale.cpp | 4 +- src/event/market/Order.cpp | 6 +- src/event/market/OtcMarketsOrder.cpp | 6 +- src/event/market/Profile.cpp | 6 +- src/event/market/Quote.cpp | 6 +- src/event/market/SpreadOrder.cpp | 6 +- src/event/market/Summary.cpp | 6 +- src/event/market/TimeAndSale.cpp | 6 +- src/event/market/Trade.cpp | 6 +- src/event/market/TradeETH.cpp | 6 +- src/event/misc/Message.cpp | 6 +- src/event/option/Greeks.cpp | 6 +- src/event/option/Series.cpp | 6 +- src/event/option/TheoPrice.cpp | 6 +- src/event/option/Underlying.cpp | 6 +- src/exceptions/InvalidArgumentException.cpp | 16 ++ src/internal/Common.cpp | 29 ++++ src/ipf/live/InstrumentProfileConnection.cpp | 2 +- src/isolated/api/IsolatedDXEndpoint.cpp | 48 +++--- src/isolated/api/IsolatedDXFeed.cpp | 2 +- .../api/IsolatedDXFeedSubscription.cpp | 56 +++---- src/isolated/api/IsolatedDXPublisher.cpp | 6 +- ...latedDXPublisherObservableSubscription.cpp | 14 +- ...edObservableSubscriptionChangeListener.cpp | 6 +- src/isolated/auth/IsolatedAuthToken.cpp | 10 +- src/isolated/internal/IsolatedObject.cpp | 8 +- src/isolated/internal/IsolatedString.cpp | 4 +- src/isolated/internal/IsolatedTimeFormat.cpp | 8 +- .../ipf/IsolatedInstrumentProfile.cpp | 144 +++++++++--------- .../ipf/IsolatedInstrumentProfileReader.cpp | 12 +- src/isolated/promise/IsolatedPromise.cpp | 22 +-- src/isolated/util/IsolatedTimePeriod.cpp | 6 +- src/ondemand/OnDemandService.cpp | 2 +- src/schedule/Day.cpp | 2 +- src/schedule/Schedule.cpp | 8 +- src/schedule/Session.cpp | 2 +- src/symbols/StringSymbol.cpp | 2 +- src/symbols/SymbolWrapper.cpp | 4 +- 91 files changed, 549 insertions(+), 431 deletions(-) create mode 100644 include/dxfeed_graal_cpp_api/exceptions/InvalidArgumentException.hpp create mode 100644 src/exceptions/InvalidArgumentException.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index a4f9563e8..526b63efc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -200,6 +200,7 @@ set(dxFeedGraalCxxApi_InternalUtilsDebug_Sources set(dxFeedGraalCxxApi_Exceptions_Sources src/exceptions/RuntimeException.cpp + src/exceptions/InvalidArgumentException.cpp src/exceptions/GraalException.cpp src/exceptions/JavaException.cpp ) diff --git a/include/dxfeed_graal_cpp_api/api.hpp b/include/dxfeed_graal_cpp_api/api.hpp index eaf5aafb5..c11a19e3b 100644 --- a/include/dxfeed_graal_cpp_api/api.hpp +++ b/include/dxfeed_graal_cpp_api/api.hpp @@ -53,6 +53,7 @@ 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" diff --git a/include/dxfeed_graal_cpp_api/api/DXEndpoint.hpp b/include/dxfeed_graal_cpp_api/api/DXEndpoint.hpp index d294e4e75..f82308904 100644 --- a/include/dxfeed_graal_cpp_api/api/DXEndpoint.hpp +++ b/include/dxfeed_graal_cpp_api/api/DXEndpoint.hpp @@ -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 */ @@ -481,7 +481,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared { // 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 create(void *endpointHandle, Role role, @@ -509,7 +509,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared { * @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 */ @@ -533,7 +533,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared { * * @param role The role of DXEndpoint instance * @return The DXEndpoint instance - * @throws std::invalid_argument + * @throws InvalidArgumentException * @throws JavaException * @throws GraalException */ @@ -546,7 +546,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared { * 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 */ @@ -559,7 +559,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared { * @ref DXEndpoint::newBuilder() "newBuilder()"->@ref Builder::build() "build()" * * @return the created endpoint. - * @throws std::invalid_argument + * @throws InvalidArgumentException * @throws JavaException * @throws GraalException */ @@ -573,7 +573,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared { * * @param role the role. * @return the created endpoint. - * @throws std::invalid_argument + * @throws InvalidArgumentException * @throws JavaException * @throws GraalException */ @@ -594,7 +594,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared { * @return the state. * * @see DXEndpoint - * @throws std::invalid_argument + * @throws InvalidArgumentException * @throws JavaException * @throws GraalException */ @@ -602,7 +602,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared { /** * @return `true` if the endpoint is closed - * @throws std::invalid_argument + * @throws InvalidArgumentException * @throws JavaException * @throws GraalException */ @@ -658,7 +658,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared { * @param user The user name. * * @return this DXEndpoint. - * @throws std::invalid_argument + * @throws InvalidArgumentException * @throws JavaException * @throws GraalException */ @@ -672,7 +672,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared { * @param password The password. * * @return this DXEndpoint. - * @throws std::invalid_argument + * @throws InvalidArgumentException * @throws JavaException * @throws GraalException */ @@ -706,7 +706,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared { * @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 */ @@ -728,7 +728,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared { * * [Javadoc.](https://docs.dxfeed.com/dxfeed/api/com/dxfeed/api/DXEndpoint.html#reconnect--) * - * @throws std::invalid_argument + * @throws InvalidArgumentException * @throws JavaException * @throws GraalException */ @@ -744,7 +744,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared { * * [Javadoc.](https://docs.dxfeed.com/dxfeed/api/com/dxfeed/api/DXEndpoint.html#disconnect--) * - * @throws std::invalid_argument + * @throws InvalidArgumentException * @throws JavaException * @throws GraalException */ @@ -760,7 +760,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared { * * [Javadoc.](https://docs.dxfeed.com/dxfeed/api/com/dxfeed/api/DXEndpoint.html#disconnectAndClear--) * - * @throws std::invalid_argument + * @throws InvalidArgumentException * @throws JavaException * @throws GraalException */ @@ -775,7 +775,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared { * * [Javadoc.](https://docs.dxfeed.com/dxfeed/api/com/dxfeed/api/DXEndpoint.html#close--) * - * @throws std::invalid_argument + * @throws InvalidArgumentException * @throws JavaException * @throws GraalException */ @@ -792,7 +792,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared { * * [Javadoc.](https://docs.dxfeed.com/dxfeed/api/com/dxfeed/api/DXEndpoint.html#awaitNotConnected--) * - * @throws std::invalid_argument + * @throws InvalidArgumentException * @throws JavaException * @throws GraalException */ @@ -805,7 +805,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared { * * [Javadoc.](https://docs.dxfeed.com/dxfeed/api/com/dxfeed/api/DXEndpoint.html#awaitProcessed--) * - * @throws std::invalid_argument + * @throws InvalidArgumentException * @throws JavaException * @throws GraalException */ @@ -822,7 +822,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared { * * [Javadoc.](https://docs.dxfeed.com/dxfeed/api/com/dxfeed/api/DXEndpoint.html#closeAndAwaitTermination--) * - * @throws std::invalid_argument + * @throws InvalidArgumentException * @throws JavaException * @throws GraalException */ @@ -833,7 +833,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared { /** * @return The feed that is associated with this endpoint. - * @throws std::invalid_argument + * @throws InvalidArgumentException * @throws JavaException * @throws GraalException */ @@ -841,7 +841,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared { /** * @return The publisher that is associated with this endpoint. - * @throws std::invalid_argument + * @throws InvalidArgumentException * @throws JavaException * @throws GraalException */ @@ -852,7 +852,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared { * * 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 */ @@ -880,7 +880,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared { * or "dxpublisher.properties" for the Role::PUBLISHER role. * * Non thread-safe. - * @throws std::invalid_argument + * @throws InvalidArgumentException * @throws JavaException * @throws GraalException */ @@ -900,7 +900,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared { * @param name The endpoint's name * * @return `this` endpoint builder. - * @throws std::invalid_argument + * @throws InvalidArgumentException * @throws JavaException * @throws GraalException */ @@ -913,7 +913,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared { * @param role The endpoint's role * * @return `this` endpoint builder. - * @throws std::invalid_argument + * @throws InvalidArgumentException * @throws JavaException * @throws GraalException */ @@ -927,7 +927,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared { * @return `this` endpoint builder. * * @see ::supportsProperty(const std::string&) - * @throws std::invalid_argument + * @throws InvalidArgumentException * @throws JavaException * @throws GraalException */ @@ -941,7 +941,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared { * @return `this` endpoint builder. * * @see ::withProperty(const std::string&, const std::string&) - * @throws std::invalid_argument + * @throws InvalidArgumentException * @throws JavaException * @throws GraalException */ @@ -965,7 +965,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared { * @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 */ @@ -975,7 +975,7 @@ struct DXFCPP_EXPORT DXEndpoint : public RequireMakeShared { * Builds DXEndpoint instance. * * @return the created endpoint. - * @throws std::invalid_argument + * @throws InvalidArgumentException * @throws JavaException * @throws GraalException */ diff --git a/include/dxfeed_graal_cpp_api/api/osub/IndexedEventSubscriptionSymbol.hpp b/include/dxfeed_graal_cpp_api/api/osub/IndexedEventSubscriptionSymbol.hpp index 80c0fdab9..04a088c66 100644 --- a/include/dxfeed_graal_cpp_api/api/osub/IndexedEventSubscriptionSymbol.hpp +++ b/include/dxfeed_graal_cpp_api/api/osub/IndexedEventSubscriptionSymbol.hpp @@ -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); @@ -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); diff --git a/include/dxfeed_graal_cpp_api/api/osub/TimeSeriesSubscriptionSymbol.hpp b/include/dxfeed_graal_cpp_api/api/osub/TimeSeriesSubscriptionSymbol.hpp index 71286b21b..01acf3ca3 100644 --- a/include/dxfeed_graal_cpp_api/api/osub/TimeSeriesSubscriptionSymbol.hpp +++ b/include/dxfeed_graal_cpp_api/api/osub/TimeSeriesSubscriptionSymbol.hpp @@ -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); @@ -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); diff --git a/include/dxfeed_graal_cpp_api/api/osub/WildcardSymbol.hpp b/include/dxfeed_graal_cpp_api/api/osub/WildcardSymbol.hpp index 66da25235..01c725cb2 100644 --- a/include/dxfeed_graal_cpp_api/api/osub/WildcardSymbol.hpp +++ b/include/dxfeed_graal_cpp_api/api/osub/WildcardSymbol.hpp @@ -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); @@ -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); diff --git a/include/dxfeed_graal_cpp_api/event/IndexedEventSource.hpp b/include/dxfeed_graal_cpp_api/event/IndexedEventSource.hpp index 60a4a38c1..1070fcde6 100644 --- a/include/dxfeed_graal_cpp_api/event/IndexedEventSource.hpp +++ b/include/dxfeed_graal_cpp_api/event/IndexedEventSource.hpp @@ -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); @@ -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); diff --git a/include/dxfeed_graal_cpp_api/event/candle/Candle.hpp b/include/dxfeed_graal_cpp_api/event/candle/Candle.hpp index 787022f9d..37caec072 100644 --- a/include/dxfeed_graal_cpp_api/event/candle/Candle.hpp +++ b/include/dxfeed_graal_cpp_api/event/candle/Candle.hpp @@ -14,6 +14,9 @@ DXFCXX_DISABLE_MSC_WARNINGS_PUSH(4251) #include #include "../../internal/Common.hpp" + +#include "../../exceptions/InvalidArgumentException.hpp" + #include "../EventType.hpp" #include "../EventTypeEnum.hpp" #include "../IndexedEventSource.hpp" @@ -126,7 +129,7 @@ class DXFCPP_EXPORT Candle final : public EventTypeWithSymbol, * * @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); @@ -143,6 +146,7 @@ class DXFCPP_EXPORT Candle final : public EventTypeWithSymbol, * 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); @@ -343,13 +347,13 @@ class DXFCPP_EXPORT Candle final : public EventTypeWithSymbol, * * @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(sequence) <= MAX_SEQUENCE); if (sequence < 0 || static_cast(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); diff --git a/include/dxfeed_graal_cpp_api/event/candle/CandleAlignment.hpp b/include/dxfeed_graal_cpp_api/event/candle/CandleAlignment.hpp index 4640e8d82..9489686e9 100644 --- a/include/dxfeed_graal_cpp_api/event/candle/CandleAlignment.hpp +++ b/include/dxfeed_graal_cpp_api/event/candle/CandleAlignment.hpp @@ -8,6 +8,7 @@ DXFCXX_DISABLE_MSC_WARNINGS_PUSH(4251) #include "../../internal/utils/StringUtils.hpp" +#include "../../exceptions/InvalidArgumentException.hpp" #include "../market/MarketEventSymbols.hpp" #include "CandleSymbolAttribute.hpp" @@ -101,7 +102,7 @@ struct DXFCPP_EXPORT CandleAlignment : public CandleSymbolAttribute { * * @param s The string representation of candle alignment. * @return The candle alignment (reference) - * @throws std::invalid_argument if the string representation is invalid. + * @throws InvalidArgumentException if the string representation is invalid. */ static std::reference_wrapper parse(const dxfcpp::StringLikeWrapper &s) { auto found = BY_STRING.find(s); @@ -118,7 +119,7 @@ struct DXFCPP_EXPORT CandleAlignment : public CandleSymbolAttribute { } } - throw std::invalid_argument("Unknown candle alignment: " + s); + throw InvalidArgumentException("Unknown candle alignment: " + s); } /** @@ -152,7 +153,7 @@ struct DXFCPP_EXPORT CandleAlignment : public CandleSymbolAttribute { try { auto other = parse(a.value()); - if (other == DEFAULT) { + if (other.get() == DEFAULT) { return MarketEventSymbols::removeAttributeStringByKey(symbol, ATTRIBUTE_KEY); } @@ -160,6 +161,8 @@ struct DXFCPP_EXPORT CandleAlignment : public CandleSymbolAttribute { return MarketEventSymbols::changeAttributeStringByKey(symbol, ATTRIBUTE_KEY, other.get().toString()); } + return symbol; + } catch (const InvalidArgumentException &) { return symbol; } catch (const std::invalid_argument &) { return symbol; diff --git a/include/dxfeed_graal_cpp_api/event/candle/CandlePeriod.hpp b/include/dxfeed_graal_cpp_api/event/candle/CandlePeriod.hpp index c0835a3c3..50b98ba06 100644 --- a/include/dxfeed_graal_cpp_api/event/candle/CandlePeriod.hpp +++ b/include/dxfeed_graal_cpp_api/event/candle/CandlePeriod.hpp @@ -234,6 +234,8 @@ struct DXFCPP_EXPORT CandlePeriod : public CandleSymbolAttribute { return MarketEventSymbols::changeAttributeStringByKey(symbol, ATTRIBUTE_KEY, other.toString()); } + return symbol; + } catch (const InvalidArgumentException &) { return symbol; } catch (const std::invalid_argument &) { return symbol; diff --git a/include/dxfeed_graal_cpp_api/event/candle/CandlePrice.hpp b/include/dxfeed_graal_cpp_api/event/candle/CandlePrice.hpp index b547e1141..d6142542e 100644 --- a/include/dxfeed_graal_cpp_api/event/candle/CandlePrice.hpp +++ b/include/dxfeed_graal_cpp_api/event/candle/CandlePrice.hpp @@ -7,6 +7,7 @@ DXFCXX_DISABLE_MSC_WARNINGS_PUSH(4251) +#include "../../exceptions/InvalidArgumentException.hpp" #include "../../internal/utils/StringUtils.hpp" #include "../market/MarketEventSymbols.hpp" #include "CandleSymbolAttribute.hpp" @@ -117,13 +118,11 @@ struct DXFCPP_EXPORT CandlePrice : public CandleSymbolAttribute { * * @param s The string representation of candle price type. * @return The candle price type (reference). + * @throws InvalidArgumentException if argument is empty or invalid */ static std::reference_wrapper parse(const dxfcpp::StringLikeWrapper &s) { - auto sw = s.operator std::string_view(); - auto n = sw.length(); - - if (n == 0) { - throw std::invalid_argument("Missing candle price"); + if (s.empty()) { + throw InvalidArgumentException("Missing candle price"); } auto found = BY_STRING.find(s); @@ -135,12 +134,12 @@ struct DXFCPP_EXPORT CandlePrice : public CandleSymbolAttribute { for (const auto &priceRef : VALUES) { const auto &priceStr = priceRef.get().toString(); - if (priceStr.length() >= n && iEquals(priceStr.substr(0, n), s)) { + if (priceStr.length() >= s.length() && iEquals(priceStr.substr(0, s.length()), s)) { return priceRef; } } - throw std::invalid_argument("Unknown candle price: " + s); + throw InvalidArgumentException("Unknown candle price: " + s); } /** @@ -163,8 +162,7 @@ struct DXFCPP_EXPORT CandlePrice : public CandleSymbolAttribute { * @param symbol candle symbol string. * @return candle symbol string with the normalized representation of the the candle price type attribute. */ - static std::string - normalizeAttributeForSymbol(const dxfcpp::StringLikeWrapper &symbol) { + static std::string normalizeAttributeForSymbol(const dxfcpp::StringLikeWrapper &symbol) { auto a = MarketEventSymbols::getAttributeStringByKey(symbol, ATTRIBUTE_KEY); if (!a) { @@ -174,7 +172,7 @@ struct DXFCPP_EXPORT CandlePrice : public CandleSymbolAttribute { try { auto other = parse(a.value()); - if (other == DEFAULT) { + if (other.get() == DEFAULT) { return MarketEventSymbols::removeAttributeStringByKey(symbol, ATTRIBUTE_KEY); } @@ -182,6 +180,8 @@ struct DXFCPP_EXPORT CandlePrice : public CandleSymbolAttribute { return MarketEventSymbols::changeAttributeStringByKey(symbol, ATTRIBUTE_KEY, other.get().toString()); } + return symbol; + } catch (const InvalidArgumentException &) { return symbol; } catch (const std::invalid_argument &) { return symbol; diff --git a/include/dxfeed_graal_cpp_api/event/candle/CandlePriceLevel.hpp b/include/dxfeed_graal_cpp_api/event/candle/CandlePriceLevel.hpp index 5db0211e8..121618edf 100644 --- a/include/dxfeed_graal_cpp_api/event/candle/CandlePriceLevel.hpp +++ b/include/dxfeed_graal_cpp_api/event/candle/CandlePriceLevel.hpp @@ -117,10 +117,11 @@ struct DXFCPP_EXPORT CandlePriceLevel : public CandleSymbolAttribute { * * @param value candle price level value. * @return candle price level with the given value and type. + * @throws InvalidArgumentException if value is incorrect */ static CandlePriceLevel valueOf(double value) { if (std::isinf(value) || (value == 0.0 && std::signbit(value))) { - throw std::invalid_argument("Incorrect candle price level: " + dxfcpp::toString(value)); + throw InvalidArgumentException("Incorrect candle price level: " + dxfcpp::toString(value)); } return std::isnan(value) ? DEFAULT : CandlePriceLevel(value); @@ -164,6 +165,8 @@ struct DXFCPP_EXPORT CandlePriceLevel : public CandleSymbolAttribute { return MarketEventSymbols::changeAttributeStringByKey(symbol, ATTRIBUTE_KEY, other.toString()); } + return symbol; + } catch (const InvalidArgumentException &) { return symbol; } catch (const std::invalid_argument &) { return symbol; diff --git a/include/dxfeed_graal_cpp_api/event/candle/CandleSession.hpp b/include/dxfeed_graal_cpp_api/event/candle/CandleSession.hpp index 8e0d6b117..f22b722d1 100644 --- a/include/dxfeed_graal_cpp_api/event/candle/CandleSession.hpp +++ b/include/dxfeed_graal_cpp_api/event/candle/CandleSession.hpp @@ -113,14 +113,11 @@ struct DXFCPP_EXPORT CandleSession : public CandleSymbolAttribute { * * @param s The string representation of candle session attribute. * @return The candle session attribute (reference). - * @throws std::invalid_argument + * @throws InvalidArgumentException if argument is empty or invalid */ static std::reference_wrapper parse(const dxfcpp::StringLikeWrapper &s) { - auto sw = s.operator std::string_view(); - auto n = sw.length(); - - if (n == 0) { - throw std::invalid_argument("Missing candle session"); + if (s.empty()) { + throw InvalidArgumentException("Missing candle session"); } auto found = BY_STRING.find(s); @@ -132,12 +129,12 @@ struct DXFCPP_EXPORT CandleSession : public CandleSymbolAttribute { for (const auto &sessionRef : VALUES) { const auto &sessionStr = sessionRef.get().toString(); - if (sessionStr.length() >= n && iEquals(sessionStr.substr(0, n), s)) { + if (sessionStr.length() >= s.length() && iEquals(sessionStr.substr(0, s.length()), s)) { return sessionRef; } } - throw std::invalid_argument("Unknown candle session: " + s); + throw InvalidArgumentException("Unknown candle session: " + s); } /** @@ -169,7 +166,7 @@ struct DXFCPP_EXPORT CandleSession : public CandleSymbolAttribute { try { auto other = parse(a.value()); - if (other == DEFAULT) { + if (other.get() == DEFAULT) { return MarketEventSymbols::removeAttributeStringByKey(symbol, ATTRIBUTE_KEY); } @@ -177,6 +174,8 @@ struct DXFCPP_EXPORT CandleSession : public CandleSymbolAttribute { return MarketEventSymbols::changeAttributeStringByKey(symbol, ATTRIBUTE_KEY, other.get().toString()); } + return symbol; + } catch (const InvalidArgumentException &) { return symbol; } catch (const std::invalid_argument &) { return symbol; diff --git a/include/dxfeed_graal_cpp_api/event/candle/CandleSymbol.hpp b/include/dxfeed_graal_cpp_api/event/candle/CandleSymbol.hpp index ba0b26a54..313d87dd2 100644 --- a/include/dxfeed_graal_cpp_api/event/candle/CandleSymbol.hpp +++ b/include/dxfeed_graal_cpp_api/event/candle/CandleSymbol.hpp @@ -273,6 +273,7 @@ struct DXFCPP_EXPORT 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); @@ -281,7 +282,7 @@ struct DXFCPP_EXPORT CandleSymbol { * * @param graalNative The pointer to the dxFeed Graal SDK structure. * @return The object of current type. - * @throws std::invalid_argument + * @throws InvalidArgumentException */ static CandleSymbol fromGraal(void *graalNative); diff --git a/include/dxfeed_graal_cpp_api/event/candle/CandleType.hpp b/include/dxfeed_graal_cpp_api/event/candle/CandleType.hpp index def9246f6..60c0536f2 100644 --- a/include/dxfeed_graal_cpp_api/event/candle/CandleType.hpp +++ b/include/dxfeed_graal_cpp_api/event/candle/CandleType.hpp @@ -158,7 +158,7 @@ struct DXFCPP_EXPORT CandleType { * distinguish it from CandleType::MINUTE that is represented as `"m"`. * * @return string representation of this candle price type. - * @throws std::invalid_argument if the string representation is invalid. + * @throws InvalidArgumentException if the string representation is invalid. */ const std::string &toString() const & noexcept { return string_; @@ -171,16 +171,14 @@ struct DXFCPP_EXPORT CandleType { * * @param s The string representation of candle type. * @return A candle type. + * @throws InvalidArgumentException if argument is empty or invalid */ static std::reference_wrapper parse(const dxfcpp::StringLikeWrapper &s) { - auto sw = s.operator std::string_view(); - auto n = sw.length(); - - if (n == 0) { - throw std::invalid_argument("Missing candle type"); + if (s.empty()) { + throw InvalidArgumentException("Missing candle type"); } - auto result = BY_STRING.find(sw); + auto result = BY_STRING.find(s); if (result != BY_STRING.end()) { return result->second; @@ -190,17 +188,17 @@ struct DXFCPP_EXPORT CandleType { const auto &name = typeRef.get().getName(); // Tick|TICK|tick, Minute|MINUTE|minute, Second|SECOND|second, etc - if (name.length() >= n && iEquals(name.substr(0, n), sw)) { + if (name.length() >= s.length() && iEquals(name.substr(0, s.length()), s)) { return typeRef; } // Ticks, Minutes, Seconds, etc - if (sw.ends_with("s") && iEquals(name, sw.substr(0, n - 1))) { + if (s.ends_with("s") && iEquals(name, s.substr(0, s.length() - 1))) { return typeRef; } } - throw std::invalid_argument("Unknown candle type: " + s); + throw InvalidArgumentException("Unknown candle type: " + s); } bool operator==(const CandleType &candleType) const noexcept { diff --git a/include/dxfeed_graal_cpp_api/event/market/AnalyticOrder.hpp b/include/dxfeed_graal_cpp_api/event/market/AnalyticOrder.hpp index abdb534a1..d40d7cf2c 100644 --- a/include/dxfeed_graal_cpp_api/event/market/AnalyticOrder.hpp +++ b/include/dxfeed_graal_cpp_api/event/market/AnalyticOrder.hpp @@ -89,7 +89,7 @@ class DXFCPP_EXPORT AnalyticOrder final : public Order { * * @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); @@ -106,6 +106,7 @@ class DXFCPP_EXPORT AnalyticOrder final : public Order { * 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); diff --git a/include/dxfeed_graal_cpp_api/event/market/OptionSale.hpp b/include/dxfeed_graal_cpp_api/event/market/OptionSale.hpp index acb69bf3b..042a007bd 100644 --- a/include/dxfeed_graal_cpp_api/event/market/OptionSale.hpp +++ b/include/dxfeed_graal_cpp_api/event/market/OptionSale.hpp @@ -107,7 +107,7 @@ class DXFCPP_EXPORT OptionSale final : public MarketEvent, public IndexedEvent { * * @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); @@ -124,6 +124,7 @@ class DXFCPP_EXPORT OptionSale final : public MarketEvent, public IndexedEvent { * 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); @@ -409,12 +410,13 @@ class DXFCPP_EXPORT OptionSale final : public MarketEvent, public IndexedEvent { * * @param sequence the sequence. * @see ::getSequence() + * @throws InvalidArgumentException */ void setSequence(std::int32_t sequence) { assert(sequence >= 0 && static_cast(sequence) <= MAX_SEQUENCE); if (sequence < 0 || static_cast(sequence) > MAX_SEQUENCE) { - throw std::invalid_argument("Invalid sequence value = " + std::to_string(sequence)); + throw InvalidArgumentException("Invalid sequence value = " + std::to_string(sequence)); } data_.timeSequence = orOp(andOp(data_.timeSequence, ~MAX_SEQUENCE), sequence); diff --git a/include/dxfeed_graal_cpp_api/event/market/Order.hpp b/include/dxfeed_graal_cpp_api/event/market/Order.hpp index d0ac6bb4f..208ae0b16 100644 --- a/include/dxfeed_graal_cpp_api/event/market/Order.hpp +++ b/include/dxfeed_graal_cpp_api/event/market/Order.hpp @@ -121,7 +121,7 @@ class DXFCPP_EXPORT Order : public OrderBase { * * @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); @@ -138,6 +138,7 @@ class DXFCPP_EXPORT Order : public OrderBase { * 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); diff --git a/include/dxfeed_graal_cpp_api/event/market/OrderBase.hpp b/include/dxfeed_graal_cpp_api/event/market/OrderBase.hpp index 42f217f39..0b77c52f5 100644 --- a/include/dxfeed_graal_cpp_api/event/market/OrderBase.hpp +++ b/include/dxfeed_graal_cpp_api/event/market/OrderBase.hpp @@ -234,10 +234,11 @@ class DXFCPP_EXPORT OrderBase : public MarketEvent, public IndexedEvent { * Use OrderBase::setSource() after invocation of this method to set the desired value of source. * * @param index unique per-symbol index of this order. + * @throws InvalidArgumentException */ void setIndex(std::int64_t index) override { if (index < 0) { - throw std::invalid_argument("Negative index: " + std::to_string(index)); + throw InvalidArgumentException("Negative index: " + std::to_string(index)); } orderBaseData_.index = index; @@ -333,10 +334,11 @@ class DXFCPP_EXPORT OrderBase : public MarketEvent, public IndexedEvent { * @param sequence the sequence. * * @see OrderBase::getSequence() + * @throws InvalidArgumentException */ void setSequence(std::int32_t sequence) { if (sequence < 0 || static_cast(sequence) > MAX_SEQUENCE) { - throw std::invalid_argument("Invalid sequence value = " + std::to_string(sequence)); + throw InvalidArgumentException("Invalid sequence value = " + std::to_string(sequence)); } orderBaseData_.timeSequence = orOp(andOp(orderBaseData_.timeSequence, ~MAX_SEQUENCE), sequence); diff --git a/include/dxfeed_graal_cpp_api/event/market/OrderSource.hpp b/include/dxfeed_graal_cpp_api/event/market/OrderSource.hpp index 41a34497f..9efed430e 100644 --- a/include/dxfeed_graal_cpp_api/event/market/OrderSource.hpp +++ b/include/dxfeed_graal_cpp_api/event/market/OrderSource.hpp @@ -71,7 +71,7 @@ class DXFCPP_EXPORT OrderSource final : public IndexedEventSource { auto n = name.length(); if (n == 0 || n > 4) { - throw std::invalid_argument("Source name must contain from 1 to 4 characters"); + throw InvalidArgumentException("Source name must contain from 1 to 4 characters"); } for (auto c : name) { @@ -87,12 +87,12 @@ class DXFCPP_EXPORT OrderSource final : public IndexedEventSource { return; } - throw std::invalid_argument("Source name must contain only alphanumeric characters"); + throw InvalidArgumentException("Source name must contain only alphanumeric characters"); } static std::string decodeName(std::int32_t id) { if (id == 0) { - throw std::invalid_argument("Source name must contain from 1 to 4 characters"); + throw InvalidArgumentException("Source name must contain from 1 to 4 characters"); } std::string name(4, '\0'); @@ -130,7 +130,7 @@ class DXFCPP_EXPORT OrderSource final : public IndexedEventSource { return PUB_SPREAD_ORDER; } - throw std::invalid_argument("Invalid order event type: " + eventType.getName()); + throw InvalidArgumentException("Invalid order event type: " + eventType.getName()); } /** diff --git a/include/dxfeed_graal_cpp_api/event/market/OtcMarketsOrder.hpp b/include/dxfeed_graal_cpp_api/event/market/OtcMarketsOrder.hpp index 506ede3de..068a02c82 100644 --- a/include/dxfeed_graal_cpp_api/event/market/OtcMarketsOrder.hpp +++ b/include/dxfeed_graal_cpp_api/event/market/OtcMarketsOrder.hpp @@ -156,7 +156,7 @@ class DXFCPP_EXPORT OtcMarketsOrder final : public Order { * * @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); @@ -173,6 +173,7 @@ class DXFCPP_EXPORT OtcMarketsOrder final : public Order { * 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); diff --git a/include/dxfeed_graal_cpp_api/event/market/Profile.hpp b/include/dxfeed_graal_cpp_api/event/market/Profile.hpp index 91064111f..16c00f7d8 100644 --- a/include/dxfeed_graal_cpp_api/event/market/Profile.hpp +++ b/include/dxfeed_graal_cpp_api/event/market/Profile.hpp @@ -87,7 +87,7 @@ class DXFCPP_EXPORT Profile final : public MarketEvent, public LastingEvent { * * @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); @@ -104,6 +104,7 @@ class DXFCPP_EXPORT Profile final : public MarketEvent, public LastingEvent { * 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); diff --git a/include/dxfeed_graal_cpp_api/event/market/Quote.hpp b/include/dxfeed_graal_cpp_api/event/market/Quote.hpp index 68df6ad92..8d8ff6889 100644 --- a/include/dxfeed_graal_cpp_api/event/market/Quote.hpp +++ b/include/dxfeed_graal_cpp_api/event/market/Quote.hpp @@ -80,7 +80,7 @@ class DXFCPP_EXPORT Quote final : public MarketEvent, public LastingEvent { * * @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); @@ -97,6 +97,7 @@ class DXFCPP_EXPORT Quote final : public MarketEvent, public LastingEvent { * 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); @@ -153,12 +154,13 @@ class DXFCPP_EXPORT Quote final : public MarketEvent, public LastingEvent { * @param sequence The sequence. * * @see Quote::getSequence() + * @throws InvalidArgumentException */ void setSequence(std::int32_t sequence) { assert(sequence >= 0 && static_cast(sequence) <= MAX_SEQUENCE); if (sequence < 0 || static_cast(sequence) > MAX_SEQUENCE) { - throw std::invalid_argument("Invalid sequence value = " + std::to_string(sequence)); + throw InvalidArgumentException("Invalid sequence value = " + std::to_string(sequence)); } data_.timeMillisSequence = orOp(andOp(data_.timeMillisSequence, ~MAX_SEQUENCE), sequence); diff --git a/include/dxfeed_graal_cpp_api/event/market/SpreadOrder.hpp b/include/dxfeed_graal_cpp_api/event/market/SpreadOrder.hpp index c41c13f84..ab943f027 100644 --- a/include/dxfeed_graal_cpp_api/event/market/SpreadOrder.hpp +++ b/include/dxfeed_graal_cpp_api/event/market/SpreadOrder.hpp @@ -120,7 +120,7 @@ class DXFCPP_EXPORT SpreadOrder : public OrderBase { * * @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); @@ -137,6 +137,7 @@ class DXFCPP_EXPORT SpreadOrder : public OrderBase { * 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); diff --git a/include/dxfeed_graal_cpp_api/event/market/Summary.hpp b/include/dxfeed_graal_cpp_api/event/market/Summary.hpp index 6e0607da4..3db8194b6 100644 --- a/include/dxfeed_graal_cpp_api/event/market/Summary.hpp +++ b/include/dxfeed_graal_cpp_api/event/market/Summary.hpp @@ -78,7 +78,7 @@ class DXFCPP_EXPORT Summary final : public MarketEvent, public LastingEvent { * * @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); @@ -95,6 +95,7 @@ class DXFCPP_EXPORT Summary final : public MarketEvent, public LastingEvent { * 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); diff --git a/include/dxfeed_graal_cpp_api/event/market/TimeAndSale.hpp b/include/dxfeed_graal_cpp_api/event/market/TimeAndSale.hpp index 6e8553e1f..495d454ed 100644 --- a/include/dxfeed_graal_cpp_api/event/market/TimeAndSale.hpp +++ b/include/dxfeed_graal_cpp_api/event/market/TimeAndSale.hpp @@ -135,7 +135,7 @@ class DXFCPP_EXPORT TimeAndSale final : public MarketEvent, public TimeSeriesEve * * @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); @@ -152,6 +152,7 @@ class DXFCPP_EXPORT TimeAndSale final : public MarketEvent, public TimeSeriesEve * 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); @@ -292,12 +293,13 @@ class DXFCPP_EXPORT TimeAndSale final : public MarketEvent, public TimeSeriesEve * * @param sequence the sequence. * @see ::getSequence() + * @throws InvalidArgumentException */ void setSequence(std::int32_t sequence) { assert(sequence >= 0 && static_cast(sequence) <= MAX_SEQUENCE); if (sequence < 0 || static_cast(sequence) > MAX_SEQUENCE) { - throw std::invalid_argument("Invalid sequence value = " + std::to_string(sequence)); + throw InvalidArgumentException("Invalid sequence value = " + std::to_string(sequence)); } data_.index = orOp(andOp(data_.index, ~MAX_SEQUENCE), sequence); diff --git a/include/dxfeed_graal_cpp_api/event/market/Trade.hpp b/include/dxfeed_graal_cpp_api/event/market/Trade.hpp index 57e70d85f..0dd1f83ad 100644 --- a/include/dxfeed_graal_cpp_api/event/market/Trade.hpp +++ b/include/dxfeed_graal_cpp_api/event/market/Trade.hpp @@ -92,7 +92,7 @@ class DXFCPP_EXPORT Trade final : public TradeBase { * * @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); @@ -109,6 +109,7 @@ class DXFCPP_EXPORT Trade final : public TradeBase { * 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); diff --git a/include/dxfeed_graal_cpp_api/event/market/TradeBase.hpp b/include/dxfeed_graal_cpp_api/event/market/TradeBase.hpp index 14494ca23..d8e54ce2f 100644 --- a/include/dxfeed_graal_cpp_api/event/market/TradeBase.hpp +++ b/include/dxfeed_graal_cpp_api/event/market/TradeBase.hpp @@ -192,12 +192,13 @@ class DXFCPP_EXPORT TradeBase : public MarketEvent, public LastingEvent { * * @param sequence the sequence. * @see TradeBase::getSequence() + * @throws InvalidArgumentException */ void setSequence(std::int32_t sequence) { assert(sequence >= 0 && static_cast(sequence) <= MAX_SEQUENCE); if (sequence < 0 || static_cast(sequence) > MAX_SEQUENCE) { - throw std::invalid_argument("Invalid sequence value = " + std::to_string(sequence)); + throw InvalidArgumentException("Invalid sequence value = " + std::to_string(sequence)); } tradeBaseData_.timeSequence = orOp(andOp(tradeBaseData_.timeSequence, ~MAX_SEQUENCE), sequence); diff --git a/include/dxfeed_graal_cpp_api/event/market/TradeETH.hpp b/include/dxfeed_graal_cpp_api/event/market/TradeETH.hpp index 2fa8122e4..9ef8f435d 100644 --- a/include/dxfeed_graal_cpp_api/event/market/TradeETH.hpp +++ b/include/dxfeed_graal_cpp_api/event/market/TradeETH.hpp @@ -117,7 +117,7 @@ class DXFCPP_EXPORT TradeETH final : public TradeBase { * * @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); @@ -134,6 +134,7 @@ class DXFCPP_EXPORT TradeETH final : public TradeBase { * 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); diff --git a/include/dxfeed_graal_cpp_api/event/misc/Message.hpp b/include/dxfeed_graal_cpp_api/event/misc/Message.hpp index a1534bb17..38c8b3be8 100644 --- a/include/dxfeed_graal_cpp_api/event/misc/Message.hpp +++ b/include/dxfeed_graal_cpp_api/event/misc/Message.hpp @@ -56,7 +56,7 @@ class DXFCPP_EXPORT Message : public EventTypeWithSymbol { * * @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); @@ -73,6 +73,7 @@ class DXFCPP_EXPORT Message : public EventTypeWithSymbol { * 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); diff --git a/include/dxfeed_graal_cpp_api/event/option/Greeks.hpp b/include/dxfeed_graal_cpp_api/event/option/Greeks.hpp index 1214828fd..ea5c1f420 100644 --- a/include/dxfeed_graal_cpp_api/event/option/Greeks.hpp +++ b/include/dxfeed_graal_cpp_api/event/option/Greeks.hpp @@ -95,7 +95,7 @@ class DXFCPP_EXPORT Greeks final : public MarketEvent, public TimeSeriesEvent, p * * @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); @@ -119,6 +119,7 @@ class DXFCPP_EXPORT Greeks final : public MarketEvent, public TimeSeriesEvent, p * 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); @@ -219,12 +220,13 @@ class DXFCPP_EXPORT Greeks final : public MarketEvent, public TimeSeriesEvent, p * Changes @ref ::getSequence() "sequence number" of this event. * @param sequence the sequence. * @see ::getSequence() + * @throws InvalidArgumentException */ void setSequence(std::int32_t sequence) { assert(sequence >= 0 && static_cast(sequence) <= MAX_SEQUENCE); if (sequence < 0 || static_cast(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); diff --git a/include/dxfeed_graal_cpp_api/event/option/Series.hpp b/include/dxfeed_graal_cpp_api/event/option/Series.hpp index 0f168e9e5..46c26d65b 100644 --- a/include/dxfeed_graal_cpp_api/event/option/Series.hpp +++ b/include/dxfeed_graal_cpp_api/event/option/Series.hpp @@ -110,7 +110,7 @@ class DXFCPP_EXPORT Series final : public MarketEvent, public IndexedEvent { * * @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); @@ -127,6 +127,7 @@ class DXFCPP_EXPORT Series final : public MarketEvent, public IndexedEvent { * 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); @@ -324,12 +325,13 @@ class DXFCPP_EXPORT Series final : public MarketEvent, public IndexedEvent { * * @param sequence the sequence. * @see Series::getSequence() + * @throws InvalidArgumentException */ void setSequence(std::int32_t sequence) { assert(sequence >= 0 && static_cast(sequence) <= MAX_SEQUENCE); if (sequence < 0 || static_cast(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_.timeSequence = orOp(andOp(data_.timeSequence, ~MAX_SEQUENCE), sequence); diff --git a/include/dxfeed_graal_cpp_api/event/option/TheoPrice.hpp b/include/dxfeed_graal_cpp_api/event/option/TheoPrice.hpp index e9ef569dd..6643302c2 100644 --- a/include/dxfeed_graal_cpp_api/event/option/TheoPrice.hpp +++ b/include/dxfeed_graal_cpp_api/event/option/TheoPrice.hpp @@ -109,7 +109,7 @@ class DXFCPP_EXPORT TheoPrice final : public MarketEvent, public TimeSeriesEvent * * @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); @@ -126,6 +126,7 @@ class DXFCPP_EXPORT TheoPrice final : public MarketEvent, public TimeSeriesEvent * 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); @@ -226,12 +227,13 @@ class DXFCPP_EXPORT TheoPrice final : public MarketEvent, public TimeSeriesEvent * Changes @ref ::getSequence() "sequence number" of this event. * @param sequence the sequence. * @see ::getSequence() + * @throws InvalidArgumentException */ void setSequence(std::int32_t sequence) { assert(sequence >= 0 && static_cast(sequence) <= MAX_SEQUENCE); if (sequence < 0 || static_cast(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); diff --git a/include/dxfeed_graal_cpp_api/event/option/Underlying.hpp b/include/dxfeed_graal_cpp_api/event/option/Underlying.hpp index dc483e3cb..80aad0b94 100644 --- a/include/dxfeed_graal_cpp_api/event/option/Underlying.hpp +++ b/include/dxfeed_graal_cpp_api/event/option/Underlying.hpp @@ -105,7 +105,7 @@ class DXFCPP_EXPORT Underlying final : public MarketEvent, public TimeSeriesEven * * @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); @@ -122,6 +122,7 @@ class DXFCPP_EXPORT Underlying final : public MarketEvent, public TimeSeriesEven * 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); @@ -222,12 +223,13 @@ class DXFCPP_EXPORT Underlying final : public MarketEvent, public TimeSeriesEven * Changes @ref ::getSequence() "sequence number" of this event. * @param sequence the sequence. * @see ::getSequence() + * @throws InvalidArgumentException */ void setSequence(std::int32_t sequence) { assert(sequence >= 0 && static_cast(sequence) <= MAX_SEQUENCE); if (sequence < 0 || static_cast(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); diff --git a/include/dxfeed_graal_cpp_api/exceptions/InvalidArgumentException.hpp b/include/dxfeed_graal_cpp_api/exceptions/InvalidArgumentException.hpp new file mode 100644 index 000000000..2ced4912b --- /dev/null +++ b/include/dxfeed_graal_cpp_api/exceptions/InvalidArgumentException.hpp @@ -0,0 +1,28 @@ +// Copyright (c) 2024 Devexperts LLC. +// SPDX-License-Identifier: MPL-2.0 + +#pragma once + +#include "../internal/Conf.hpp" + +#include "../internal/Common.hpp" +#include "RuntimeException.hpp" + +DXFCXX_DISABLE_MSC_WARNINGS_PUSH(4251 4275) + +#include +#include + +DXFCPP_BEGIN_NAMESPACE + +/** + * Thrown to indicate that a method has been passed an illegal or inappropriate argument. + */ +struct DXFCPP_EXPORT InvalidArgumentException : RuntimeException { + explicit InvalidArgumentException(const StringLikeWrapper &message, + const StringLikeWrapper &additionalStackTrace = ""); +}; + +DXFCPP_END_NAMESPACE + +DXFCXX_DISABLE_MSC_WARNINGS_POP() \ No newline at end of file diff --git a/include/dxfeed_graal_cpp_api/internal/Common.hpp b/include/dxfeed_graal_cpp_api/internal/Common.hpp index b97531ac8..c9e306711 100644 --- a/include/dxfeed_graal_cpp_api/internal/Common.hpp +++ b/include/dxfeed_graal_cpp_api/internal/Common.hpp @@ -18,11 +18,7 @@ DXFCXX_DISABLE_MSC_WARNINGS_PUSH(4251) #include #include #include -#include -#include -#include #include -#include #include #include #include @@ -289,20 +285,7 @@ constexpr static std::int32_t getYearMonthDayByDayId(std::int32_t dayId) { return yyyy >= 0 ? yyyymmdd : -yyyymmdd; } -static std::int32_t getDayIdByYearMonthDay(std::int32_t year, std::int32_t month, std::int32_t day) { - if (month < 1 || month > 12) { - throw std::invalid_argument("invalid month " + std::to_string(month)); - } - - std::int32_t dayOfYear = DAY_OF_YEAR[month] + day - 1; - - if (month > 2 && year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)) { - dayOfYear++; - } - - return year * 365 + math_util::div(year - 1, 4) - math_util::div(year - 1, 100) + math_util::div(year - 1, 400) + - dayOfYear - 719527; -} +static std::int32_t getDayIdByYearMonthDay(std::int32_t year, std::int32_t month, std::int32_t day); } // namespace day_util @@ -747,6 +730,24 @@ struct StringLikeWrapper { return size(); } + bool ends_with(const StringLikeWrapper &sw) const { + if (auto sv = std::get_if(&data_); sv) { + return sv->ends_with(sw); + } else { + return std::get(data_).ends_with(sw); + } + } + + std::string substr(std::string::size_type pos = 0, std::string::size_type count = std::string::npos) const { + if (auto sv = std::get_if(&data_); sv) { + auto sv2 = sv->substr(pos, count); + + return {sv2.data(), sv->size()}; + } else { + return std::get(data_).substr(pos, count); + } + } + bool operator==(const StringLikeWrapper &sw) const { return sw.operator std::string_view() == this->operator std::string_view(); } @@ -796,9 +797,8 @@ struct StringHash { }; namespace util { -inline void throwInvalidChar(char c, const std::string &name) { - throw std::invalid_argument("Invalid " + name + ": " + encodeChar(c)); -} + +inline void throwInvalidChar(char c, const std::string &name); inline void checkChar(char c, std::uint32_t mask, const std::string &name) { if ((andOp(c, ~mask)) != 0) { diff --git a/include/dxfeed_graal_cpp_api/internal/TimeFormat.hpp b/include/dxfeed_graal_cpp_api/internal/TimeFormat.hpp index 74c5d5b00..eda13b86b 100644 --- a/include/dxfeed_graal_cpp_api/internal/TimeFormat.hpp +++ b/include/dxfeed_graal_cpp_api/internal/TimeFormat.hpp @@ -19,7 +19,7 @@ DXFCPP_BEGIN_NAMESPACE * * 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 */ diff --git a/include/dxfeed_graal_cpp_api/ipf/InstrumentProfile.hpp b/include/dxfeed_graal_cpp_api/ipf/InstrumentProfile.hpp index b929e38fb..77d88caab 100644 --- a/include/dxfeed_graal_cpp_api/ipf/InstrumentProfile.hpp +++ b/include/dxfeed_graal_cpp_api/ipf/InstrumentProfile.hpp @@ -775,7 +775,7 @@ struct DXFCPP_EXPORT InstrumentProfile final : public RequireMakeShared fromGraal(void *list); }; diff --git a/include/dxfeed_graal_cpp_api/isolated/api/IsolatedDXEndpoint.hpp b/include/dxfeed_graal_cpp_api/isolated/api/IsolatedDXEndpoint.hpp index b294b9bc6..8fcf8f2d9 100644 --- a/include/dxfeed_graal_cpp_api/isolated/api/IsolatedDXEndpoint.hpp +++ b/include/dxfeed_graal_cpp_api/isolated/api/IsolatedDXEndpoint.hpp @@ -28,7 +28,7 @@ namespace isolated::api::IsolatedDXEndpoint { * Calls the Graal SDK function `dxfg_DXEndpoint_close` in isolation. * * @param endpoint The endpoint's handle. - * @throws std::invalid_argument if endpoint handle is invalid. + * @throws InvalidArgumentException if endpoint handle is invalid. * @throws JavaException if something happened with the dxFeed API backend. * @throws GraalException if something happened with the GraalVM. */ @@ -38,7 +38,7 @@ void /* int32_t */ close(/* dxfg_endpoint_t* */ const JavaObjectHandle & * Calls the Graal SDK function `dxfg_DXEndpoint_reconnect` in isolation. * * @param endpoint The endpoint's handle. - * @throws std::invalid_argument if endpoint handle is invalid. + * @throws InvalidArgumentException if endpoint handle is invalid. * @throws JavaException if something happened with the dxFeed API backend. * @throws GraalException if something happened with the GraalVM. */ @@ -95,7 +95,7 @@ void reconnect(/* dxfg_endpoint_t* */ const JavaObjectHandle * Calls the Graal SDK function `dxfg_DXEndpoint_disconnect` in isolation. * * @param endpoint The endpoint's handle. - * @throws std::invalid_argument if endpoint handle is invalid. + * @throws InvalidArgumentException if endpoint handle is invalid. * @throws JavaException if something happened with the dxFeed API backend. * @throws GraalException if something happened with the GraalVM. */ @@ -105,7 +105,7 @@ void disconnect(/* dxfg_endpoint_t* */ const JavaObjectHandle * * @param endpoint The endpoint's handle. * @return A set of event types. - * @throws std::invalid_argument if endpoint handle is invalid. + * @throws InvalidArgumentException if endpoint handle is invalid. * @throws JavaException if something happened with the dxFeed API backend. * @throws GraalException if something happened with the GraalVM. */ @@ -223,7 +223,7 @@ void * /* dxfg_endpoint_builder_t* */ create(); * Calls the Graal SDK function `dxfg_DXEndpoint_Builder_withRole` in isolation. * @param builder The DXEndpoint::Builder's handle. * @param role The endpoint's role. - * @throws std::invalid_argument if DXEndpoint::Builder's handle is invalid. + * @throws InvalidArgumentException if DXEndpoint::Builder's handle is invalid. * @throws JavaException if something happened with the dxFeed API backend. * @throws GraalException if something happened with the GraalVM. */ @@ -239,7 +239,7 @@ withRole(/* dxfg_endpoint_builder_t * */ const JavaObjectHandle &ev * * @param sub The subscription's handle. * @return `true` if subscription is closed. - * @throws std::invalid_argument if DXFeedSubscription's handle is invalid. + * @throws InvalidArgumentException if DXFeedSubscription's handle is invalid. * @throws JavaException if something happened with the dxFeed API backend. * @throws GraalException if something happened with the GraalVM. */ @@ -56,7 +56,7 @@ bool /* int32_t */ isClosed(/* dxfg_subscription_t * */ const JavaObjectHandle /* dxfg_event_clazz_list_t* */ getEventTypes( * @param sub The subscription's handle. * @param eventType The type of event that is checked. * @return `true` if this subscription contains the corresponding event type. - * @throws std::invalid_argument if DXPublisherObservableSubscription's handle is invalid. + * @throws InvalidArgumentException if DXPublisherObservableSubscription's handle is invalid. * @throws JavaException if something happened with the dxFeed API backend. * @throws GraalException if something happened with the GraalVM. */ @@ -57,7 +57,7 @@ bool /* int32_t */ containsEventType( * * @param sub The subscription's handle. * @param listener The listener's handle. - * @throws std::invalid_argument if DXPublisherObservableSubscription's or ObservableSubscriptionChangeListener's handle + * @throws InvalidArgumentException if DXPublisherObservableSubscription's or ObservableSubscriptionChangeListener's handle * is invalid. * @throws JavaException if something happened with the dxFeed API backend. * @throws GraalException if something happened with the GraalVM. @@ -72,7 +72,7 @@ void /* int32_t */ addChangeListener( * * @param sub The subscription's handle. * @param listener The listener's handle. - * @throws std::invalid_argument if DXPublisherObservableSubscription's or ObservableSubscriptionChangeListener's handle + * @throws InvalidArgumentException if DXPublisherObservableSubscription's or ObservableSubscriptionChangeListener's handle * is invalid. * @throws JavaException if something happened with the dxFeed API backend. * @throws GraalException if something happened with the GraalVM. diff --git a/include/dxfeed_graal_cpp_api/isolated/api/osub/IsolatedObservableSubscriptionChangeListener.hpp b/include/dxfeed_graal_cpp_api/isolated/api/osub/IsolatedObservableSubscriptionChangeListener.hpp index ca3a2c15b..c3535bfef 100644 --- a/include/dxfeed_graal_cpp_api/isolated/api/osub/IsolatedObservableSubscriptionChangeListener.hpp +++ b/include/dxfeed_graal_cpp_api/isolated/api/osub/IsolatedObservableSubscriptionChangeListener.hpp @@ -23,7 +23,7 @@ namespace isolated::api::IsolatedObservableSubscriptionChangeListener { * @param userData User data, which is placed each time as a callback parameter when called from listener. * @return The ObservableSubscriptionChangeListener's handle. * - * @throws std::invalid_argument if functionSymbolsAdded or functionSymbolsRemoved or functionSubscriptionClosed is + * @throws InvalidArgumentException if functionSymbolsAdded or functionSymbolsRemoved or functionSubscriptionClosed is * nullptr. * @throws JavaException if something happened with the dxFeed API backend. * @throws GraalException if something happened with the GraalVM. diff --git a/include/dxfeed_graal_cpp_api/isolated/internal/IsolatedString.hpp b/include/dxfeed_graal_cpp_api/isolated/internal/IsolatedString.hpp index 4f26195ac..401c8f884 100644 --- a/include/dxfeed_graal_cpp_api/isolated/internal/IsolatedString.hpp +++ b/include/dxfeed_graal_cpp_api/isolated/internal/IsolatedString.hpp @@ -19,7 +19,7 @@ namespace IsolatedString { * @param string The pointer to C-string * @return `true` if OK. * - * @throws std::invalid_argument if string is nullptr. + * @throws InvalidArgumentException if string is nullptr. * @throws JavaException if something happened with the dxFeed API backend. * @throws GraalException if something happened with the GraalVM. */ @@ -35,7 +35,7 @@ namespace IsolatedStringList { * @param stringList The pointer to dxFeed Graal SDK' string list. * @return `true` if OK. * - * @throws std::invalid_argument if stringList is nullptr. + * @throws InvalidArgumentException if stringList is nullptr. * @throws JavaException if something happened with the dxFeed API backend. * @throws GraalException if something happened with the GraalVM. */ diff --git a/include/dxfeed_graal_cpp_api/isolated/promise/IsolatedPromise.hpp b/include/dxfeed_graal_cpp_api/isolated/promise/IsolatedPromise.hpp index 6ad680278..23e8e635d 100644 --- a/include/dxfeed_graal_cpp_api/isolated/promise/IsolatedPromise.hpp +++ b/include/dxfeed_graal_cpp_api/isolated/promise/IsolatedPromise.hpp @@ -22,7 +22,7 @@ namespace isolated::promise::IsolatedPromise { * * @param promise The promise's handle. * @return `true` when computation has completed normally or exceptionally or was cancelled. - * @throws std::invalid_argument if promise handle is nullptr. + * @throws InvalidArgumentException if promise handle is nullptr. * @throws JavaException if something happened with the dxFeed API backend. * @throws GraalException if something happened with the GraalVM. */ @@ -33,7 +33,7 @@ bool /* int32_t */ isDone(/* dxfg_promise_t * */ void* promise); * * @param promise The promise's handle. * @return `true` when computation has completed normally - * @throws std::invalid_argument if promise handle is nullptr. + * @throws InvalidArgumentException if promise handle is nullptr. * @throws JavaException if something happened with the dxFeed API backend. * @throws GraalException if something happened with the GraalVM. */ @@ -44,7 +44,7 @@ bool /* int32_t */ hasResult(/* dxfg_promise_t * */ void* promise); * * @param promise The promise's handle. * @return `true` when computation has completed exceptionally or was cancelled. - * @throws std::invalid_argument if promise handle is nullptr. + * @throws InvalidArgumentException if promise handle is nullptr. * @throws JavaException if something happened with the dxFeed API backend. * @throws GraalException if something happened with the GraalVM. */ @@ -55,7 +55,7 @@ bool /* int32_t */ hasException(/* dxfg_promise_t * */ void* promise); * * @param promise The promise's handle. * @return `true` when computation was cancelled. - * @throws std::invalid_argument if promise handle is nullptr. + * @throws InvalidArgumentException if promise handle is nullptr. * @throws JavaException if something happened with the dxFeed API backend. * @throws GraalException if something happened with the GraalVM. */ @@ -66,7 +66,7 @@ bool /* int32_t */ isCancelled(/* dxfg_promise_t * */ void* promise); * * @param promise The promise's handle. * @return event by promise - * @throws std::invalid_argument if promise handle is nullptr. + * @throws InvalidArgumentException if promise handle is nullptr. * @throws JavaException if something happened with the dxFeed API backend. * @throws GraalException if something happened with the GraalVM. */ @@ -77,7 +77,7 @@ std::shared_ptr /* dxfg_event_type_t* */ getResult(/* dxfg_promise_ev * * @param promise The promise's handle. * @return events by promise - * @throws std::invalid_argument if promise handle is nullptr. + * @throws InvalidArgumentException if promise handle is nullptr. * @throws JavaException if something happened with the dxFeed API backend. * @throws GraalException if something happened with the GraalVM. */ @@ -88,7 +88,7 @@ std::vector> /* dxfg_event_type_list* */ getResults(/ * * @param promise The promise's handle. * @return exception by promise - * @throws std::invalid_argument if promise handle is nullptr. + * @throws InvalidArgumentException if promise handle is nullptr. * @throws JavaException if something happened with the dxFeed API backend. * @throws GraalException if something happened with the GraalVM. */ @@ -98,7 +98,7 @@ JavaException /* dxfg_exception_t* */ getException(/* dxfg_promise_t * */ void* * Calls the Graal SDK function `dxfg_Promise_await` in isolation. * * @param promise The promise's handle. - * @throws std::invalid_argument if promise handle is nullptr. + * @throws InvalidArgumentException if promise handle is nullptr. * @throws JavaException if something happened with the dxFeed API backend. * @throws GraalException if something happened with the GraalVM. */ @@ -109,7 +109,7 @@ void /* int32_t */ await(/* dxfg_promise_t * */ void* promise); * * @param promise The promise's handle. * @param timeoutInMilliseconds The promise's timeout. - * @throws std::invalid_argument if promise handle is nullptr. + * @throws InvalidArgumentException if promise handle is nullptr. * @throws JavaException if something happened with the dxFeed API backend. * @throws GraalException if something happened with the GraalVM. */ @@ -121,7 +121,7 @@ void /* int32_t */ await(/* dxfg_promise_t * */ void* promise, std::int32_t time * @param promise The promise's handle. * @param timeoutInMilliseconds The promise's timeout. * @return `true` if the computation has completed normally; `false` when wait timed out. - * @throws std::invalid_argument if promise handle is nullptr. + * @throws InvalidArgumentException if promise handle is nullptr. * @throws JavaException if something happened with the dxFeed API backend. * @throws GraalException if something happened with the GraalVM. */ @@ -131,7 +131,7 @@ bool /* int32_t */ awaitWithoutException(/* dxfg_promise_t * */ void* promise, s * Calls the Graal SDK function `dxfg_Promise_cancel` in isolation. * * @param promise The promise's handle. - * @throws std::invalid_argument if promise handle is nullptr. + * @throws InvalidArgumentException if promise handle is nullptr. * @throws JavaException if something happened with the dxFeed API backend. * @throws GraalException if something happened with the GraalVM. */ diff --git a/include/dxfeed_graal_cpp_api/symbols/StringSymbol.hpp b/include/dxfeed_graal_cpp_api/symbols/StringSymbol.hpp index 5d3a54d88..3572f3a5b 100644 --- a/include/dxfeed_graal_cpp_api/symbols/StringSymbol.hpp +++ b/include/dxfeed_graal_cpp_api/symbols/StringSymbol.hpp @@ -79,6 +79,7 @@ struct DXFCPP_EXPORT StringSymbol 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); @@ -87,7 +88,7 @@ struct DXFCPP_EXPORT StringSymbol final { * * @param graalNative The pointer to the dxFeed Graal SDK structure. * @return The object of current type. - * @throws std::invalid_argument + * @throws InvalidArgumentException */ static StringSymbol fromGraal(void *graalNative); diff --git a/include/dxfeed_graal_cpp_api/symbols/SymbolWrapper.hpp b/include/dxfeed_graal_cpp_api/symbols/SymbolWrapper.hpp index 25e2c38c9..37bd05671 100644 --- a/include/dxfeed_graal_cpp_api/symbols/SymbolWrapper.hpp +++ b/include/dxfeed_graal_cpp_api/symbols/SymbolWrapper.hpp @@ -219,6 +219,7 @@ struct DXFCPP_EXPORT SymbolWrapper 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); @@ -227,7 +228,8 @@ struct DXFCPP_EXPORT SymbolWrapper final { * * @param graalNative The pointer to the dxFeed Graal SDK structure. * @return The object of current type. - * @throws std::invalid_argument + * @throws InvalidArgumentException + * @throws RuntimeException if symbol type is unknown */ static SymbolWrapper fromGraal(void *graalNative); diff --git a/src/api/DXEndpoint.cpp b/src/api/DXEndpoint.cpp index 7e64b5e89..2be43b6a0 100644 --- a/src/api/DXEndpoint.cpp +++ b/src/api/DXEndpoint.cpp @@ -120,7 +120,7 @@ std::unordered_map> DXEndpoint::Im std::shared_ptr DXEndpoint::create(void *endpointHandle, DXEndpoint::Role role, const std::unordered_map &properties) { if (endpointHandle == nullptr) { - throw std::invalid_argument("Unable to create DXEndpoint. The `endpointHandle` is nullptr"); + throw InvalidArgumentException("Unable to create DXEndpoint. The `endpointHandle` is nullptr"); } if constexpr (Debugger::isDebug) { diff --git a/src/api/osub/IndexedEventSubscriptionSymbol.cpp b/src/api/osub/IndexedEventSubscriptionSymbol.cpp index 3ed16136a..ffb973645 100644 --- a/src/api/osub/IndexedEventSubscriptionSymbol.cpp +++ b/src/api/osub/IndexedEventSubscriptionSymbol.cpp @@ -48,7 +48,7 @@ IndexedEventSubscriptionSymbol IndexedEventSubscriptionSymbol::fromGraal(void *g } if (graalNative == nullptr) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to create IndexedEventSubscriptionSymbol. The `graalNative` parameter is nullptr"); } diff --git a/src/api/osub/TimeSeriesSubscriptionSymbol.cpp b/src/api/osub/TimeSeriesSubscriptionSymbol.cpp index 061c44041..6019c28ce 100644 --- a/src/api/osub/TimeSeriesSubscriptionSymbol.cpp +++ b/src/api/osub/TimeSeriesSubscriptionSymbol.cpp @@ -51,7 +51,7 @@ TimeSeriesSubscriptionSymbol TimeSeriesSubscriptionSymbol::fromGraal(void *graal } if (graalNative == nullptr) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to create TimeSeriesSubscriptionSymbol. The `graalNative` parameter is nullptr"); } diff --git a/src/event/EventMapper.cpp b/src/event/EventMapper.cpp index 32add654a..e9a73983d 100644 --- a/src/event/EventMapper.cpp +++ b/src/event/EventMapper.cpp @@ -18,7 +18,7 @@ DXFCPP_BEGIN_NAMESPACE std::shared_ptr EventMapper::fromGraal(void *graalNativeEvent) { if (!graalNativeEvent) { - throw std::invalid_argument("The `graalNativeEvent` is nullptr"); + throw InvalidArgumentException("The `graalNativeEvent` is nullptr"); } // TODO: implement other types [EN-8235] @@ -34,7 +34,7 @@ std::shared_ptr EventMapper::fromGraal(void *graalNativeEvent) { case DXFG_EVENT_CANDLE: return Candle::fromGraal(e); case DXFG_EVENT_DAILY_CANDLE: - throw std::invalid_argument("Not emplemented event type: " + std::to_string(static_cast(e->clazz))); + throw InvalidArgumentException("Not emplemented event type: " + std::to_string(static_cast(e->clazz))); case DXFG_EVENT_UNDERLYING: return Underlying::fromGraal(e); case DXFG_EVENT_THEO_PRICE: @@ -44,13 +44,13 @@ std::shared_ptr EventMapper::fromGraal(void *graalNativeEvent) { case DXFG_EVENT_TRADE_ETH: return TradeETH::fromGraal(e); case DXFG_EVENT_CONFIGURATION: - throw std::invalid_argument("Not emplemented event type: " + std::to_string(static_cast(e->clazz))); + throw InvalidArgumentException("Not emplemented event type: " + std::to_string(static_cast(e->clazz))); case DXFG_EVENT_MESSAGE: return Message::fromGraal(e); case DXFG_EVENT_TIME_AND_SALE: return TimeAndSale::fromGraal(e); case DXFG_EVENT_ORDER_BASE: - throw std::invalid_argument("Not emplemented event type: " + std::to_string(static_cast(e->clazz))); + throw InvalidArgumentException("Not emplemented event type: " + std::to_string(static_cast(e->clazz))); case DXFG_EVENT_ORDER: return Order::fromGraal(e); case DXFG_EVENT_ANALYTIC_ORDER: @@ -64,7 +64,7 @@ std::shared_ptr EventMapper::fromGraal(void *graalNativeEvent) { case DXFG_EVENT_OPTION_SALE: return OptionSale::fromGraal(e); default: - throw std::invalid_argument("Unknown event type: " + std::to_string(static_cast(e->clazz))); + throw InvalidArgumentException("Unknown event type: " + std::to_string(static_cast(e->clazz))); } } @@ -115,7 +115,7 @@ void EventMapper::freeGraal(void *graalNativeEvent) { break; case DXFG_EVENT_DAILY_CANDLE: - throw std::invalid_argument("Not emplemented event type: " + std::to_string(static_cast(e->clazz))); + throw InvalidArgumentException("Not emplemented event type: " + std::to_string(static_cast(e->clazz))); case DXFG_EVENT_UNDERLYING: Underlying::freeGraal(e); @@ -134,7 +134,7 @@ void EventMapper::freeGraal(void *graalNativeEvent) { break; case DXFG_EVENT_CONFIGURATION: - throw std::invalid_argument("Not emplemented event type: " + std::to_string(static_cast(e->clazz))); + throw InvalidArgumentException("Not emplemented event type: " + std::to_string(static_cast(e->clazz))); case DXFG_EVENT_MESSAGE: Message::freeGraal(e); @@ -145,7 +145,7 @@ void EventMapper::freeGraal(void *graalNativeEvent) { break; case DXFG_EVENT_ORDER_BASE: - throw std::invalid_argument("Not emplemented event type: " + std::to_string(static_cast(e->clazz))); + throw InvalidArgumentException("Not emplemented event type: " + std::to_string(static_cast(e->clazz))); case DXFG_EVENT_ORDER: Order::freeGraal(e); @@ -172,7 +172,7 @@ void EventMapper::freeGraal(void *graalNativeEvent) { break; default: - throw std::invalid_argument("Unknown event type: " + std::to_string(static_cast(e->clazz))); + throw InvalidArgumentException("Unknown event type: " + std::to_string(static_cast(e->clazz))); } } diff --git a/src/event/candle/Candle.cpp b/src/event/candle/Candle.cpp index 96bb3862e..d25af22e5 100644 --- a/src/event/candle/Candle.cpp +++ b/src/event/candle/Candle.cpp @@ -84,11 +84,11 @@ void Candle::freeGraalData(void *graalNative) noexcept { std::shared_ptr Candle::fromGraal(void *graalNative) { if (!graalNative) { - throw std::invalid_argument("Unable to create Candle. The `graalNative` parameter is nullptr"); + throw InvalidArgumentException("Unable to create Candle. The `graalNative` parameter is nullptr"); } if (static_cast(graalNative)->clazz != dxfg_event_clazz_t::DXFG_EVENT_CANDLE) { - throw std::invalid_argument( + throw InvalidArgumentException( fmt::format("Unable to create Candle. Wrong event class {}! Expected: {}.", std::to_string(static_cast(static_cast(graalNative)->clazz)), std::to_string(static_cast(dxfg_event_clazz_t::DXFG_EVENT_CANDLE)))); @@ -120,7 +120,7 @@ void Candle::freeGraal(void *graalNative) { } if (static_cast(graalNative)->clazz != dxfg_event_clazz_t::DXFG_EVENT_CANDLE) { - throw std::invalid_argument( + throw InvalidArgumentException( fmt::format("Unable to free Candle's Graal data. Wrong event class {}! Expected: {}.", std::to_string(static_cast(static_cast(graalNative)->clazz)), std::to_string(static_cast(dxfg_event_clazz_t::DXFG_EVENT_CANDLE)))); diff --git a/src/event/market/AnalyticOrder.cpp b/src/event/market/AnalyticOrder.cpp index fa70aa55a..4df5b1bc5 100644 --- a/src/event/market/AnalyticOrder.cpp +++ b/src/event/market/AnalyticOrder.cpp @@ -49,11 +49,11 @@ void AnalyticOrder::fillGraalData(void *graalNative) const noexcept { std::shared_ptr AnalyticOrder::fromGraal(void *graalNative) { if (!graalNative) { - throw std::invalid_argument("Unable to create AnalyticOrder. The `graalNative` parameter is nullptr"); + throw InvalidArgumentException("Unable to create AnalyticOrder. The `graalNative` parameter is nullptr"); } if (static_cast(graalNative)->clazz != dxfg_event_clazz_t::DXFG_EVENT_ANALYTIC_ORDER) { - throw std::invalid_argument( + throw InvalidArgumentException( fmt::format("Unable to create AnalyticOrder. Wrong event class {}! Expected: {}.", std::to_string(static_cast(static_cast(graalNative)->clazz)), std::to_string(static_cast(dxfg_event_clazz_t::DXFG_EVENT_ANALYTIC_ORDER)))); @@ -92,7 +92,7 @@ void AnalyticOrder::freeGraal(void *graalNative) { } if (static_cast(graalNative)->clazz != dxfg_event_clazz_t::DXFG_EVENT_ANALYTIC_ORDER) { - throw std::invalid_argument( + throw InvalidArgumentException( fmt::format("Unable to free AnalyticOrder's Graal data. Wrong event class {}! Expected: {}.", std::to_string(static_cast(static_cast(graalNative)->clazz)), std::to_string(static_cast(dxfg_event_clazz_t::DXFG_EVENT_ANALYTIC_ORDER)))); diff --git a/src/event/market/OptionSale.cpp b/src/event/market/OptionSale.cpp index 0363d90e1..9c17558c0 100644 --- a/src/event/market/OptionSale.cpp +++ b/src/event/market/OptionSale.cpp @@ -90,11 +90,11 @@ void OptionSale::freeGraalData(void *graalNative) noexcept { std::shared_ptr OptionSale::fromGraal(void *graalNative) { if (!graalNative) { - throw std::invalid_argument("Unable to create OptionSale. The `graalNative` parameter is nullptr"); + throw InvalidArgumentException("Unable to create OptionSale. The `graalNative` parameter is nullptr"); } if (static_cast(graalNative)->clazz != dxfg_event_clazz_t::DXFG_EVENT_OPTION_SALE) { - throw std::invalid_argument( + throw InvalidArgumentException( fmt::format("Unable to create Order. Wrong event class {}! Expected: {}.", std::to_string(static_cast(static_cast(graalNative)->clazz)), std::to_string(static_cast(dxfg_event_clazz_t::DXFG_EVENT_OPTION_SALE)))); diff --git a/src/event/market/Order.cpp b/src/event/market/Order.cpp index 0cd045a49..8fa1ea2a2 100644 --- a/src/event/market/Order.cpp +++ b/src/event/market/Order.cpp @@ -55,11 +55,11 @@ void Order::freeGraalData(void *graalNative) noexcept { std::shared_ptr Order::fromGraal(void *graalNative) { if (!graalNative) { - throw std::invalid_argument("Unable to create Order. The `graalNative` parameter is nullptr"); + throw InvalidArgumentException("Unable to create Order. The `graalNative` parameter is nullptr"); } if (static_cast(graalNative)->clazz != dxfg_event_clazz_t::DXFG_EVENT_ORDER) { - throw std::invalid_argument( + throw InvalidArgumentException( fmt::format("Unable to create Order. Wrong event class {}! Expected: {}.", std::to_string(static_cast(static_cast(graalNative)->clazz)), std::to_string(static_cast(dxfg_event_clazz_t::DXFG_EVENT_ORDER)))); @@ -94,7 +94,7 @@ void Order::freeGraal(void *graalNative) { } if (static_cast(graalNative)->clazz != dxfg_event_clazz_t::DXFG_EVENT_ORDER) { - throw std::invalid_argument( + throw InvalidArgumentException( fmt::format("Unable to free Order's Graal data. Wrong event class {}! Expected: {}.", std::to_string(static_cast(static_cast(graalNative)->clazz)), std::to_string(static_cast(dxfg_event_clazz_t::DXFG_EVENT_ORDER)))); diff --git a/src/event/market/OtcMarketsOrder.cpp b/src/event/market/OtcMarketsOrder.cpp index 14e4b916b..11b9d5196 100644 --- a/src/event/market/OtcMarketsOrder.cpp +++ b/src/event/market/OtcMarketsOrder.cpp @@ -47,11 +47,11 @@ void OtcMarketsOrder::fillGraalData(void *graalNative) const noexcept { OtcMarketsOrder::Ptr OtcMarketsOrder::fromGraal(void *graalNative) { if (!graalNative) { - throw std::invalid_argument("Unable to create OtcMarketsOrder. The `graalNative` parameter is nullptr"); + throw InvalidArgumentException("Unable to create OtcMarketsOrder. The `graalNative` parameter is nullptr"); } if (static_cast(graalNative)->clazz != dxfg_event_clazz_t::DXFG_EVENT_OTC_MARKETS_ORDER) { - throw std::invalid_argument( + throw InvalidArgumentException( fmt::format("Unable to create OtcMarketsOrder. Wrong event class {}! Expected: {}.", std::to_string(static_cast(static_cast(graalNative)->clazz)), std::to_string(static_cast(dxfg_event_clazz_t::DXFG_EVENT_OTC_MARKETS_ORDER)))); @@ -89,7 +89,7 @@ void OtcMarketsOrder::freeGraal(void *graalNative) { } if (static_cast(graalNative)->clazz != dxfg_event_clazz_t::DXFG_EVENT_OTC_MARKETS_ORDER) { - throw std::invalid_argument( + throw InvalidArgumentException( fmt::format("Unable to free OtcMarketsOrder's Graal data. Wrong event class {}! Expected: {}.", std::to_string(static_cast(static_cast(graalNative)->clazz)), std::to_string(static_cast(dxfg_event_clazz_t::DXFG_EVENT_OTC_MARKETS_ORDER)))); diff --git a/src/event/market/Profile.cpp b/src/event/market/Profile.cpp index 764958f48..785dfb39c 100644 --- a/src/event/market/Profile.cpp +++ b/src/event/market/Profile.cpp @@ -92,11 +92,11 @@ void Profile::freeGraalData(void *graalNative) noexcept { std::shared_ptr Profile::fromGraal(void *graalNative) { if (!graalNative) { - throw std::invalid_argument("Unable to create Profile. The `graalNative` parameter is nullptr"); + throw InvalidArgumentException("Unable to create Profile. The `graalNative` parameter is nullptr"); } if (static_cast(graalNative)->clazz != dxfg_event_clazz_t::DXFG_EVENT_PROFILE) { - throw std::invalid_argument( + throw InvalidArgumentException( fmt::format("Unable to create Profile. Wrong event class {}! Expected: {}.", std::to_string(static_cast(static_cast(graalNative)->clazz)), std::to_string(static_cast(dxfg_event_clazz_t::DXFG_EVENT_PROFILE)))); @@ -143,7 +143,7 @@ void Profile::freeGraal(void *graalNative) { } if (static_cast(graalNative)->clazz != dxfg_event_clazz_t::DXFG_EVENT_PROFILE) { - throw std::invalid_argument( + throw InvalidArgumentException( fmt::format("Unable to free Profile's Graal data. Wrong event class {}! Expected: {}.", std::to_string(static_cast(static_cast(graalNative)->clazz)), std::to_string(static_cast(dxfg_event_clazz_t::DXFG_EVENT_PROFILE)))); diff --git a/src/event/market/Quote.cpp b/src/event/market/Quote.cpp index 94c87c47e..797d015f3 100644 --- a/src/event/market/Quote.cpp +++ b/src/event/market/Quote.cpp @@ -113,11 +113,11 @@ std::string Quote::toString() const { std::shared_ptr Quote::fromGraal(void *graalNative) { if (!graalNative) { - throw std::invalid_argument("Unable to create Quote. The `graalNative` parameter is nullptr"); + throw InvalidArgumentException("Unable to create Quote. The `graalNative` parameter is nullptr"); } if (static_cast(graalNative)->clazz != DXFG_EVENT_QUOTE) { - throw std::invalid_argument( + throw InvalidArgumentException( fmt::format("Unable to create Quote. Wrong event class {}! Expected: {}.", std::to_string(static_cast(static_cast(graalNative)->clazz)), std::to_string(static_cast(dxfg_event_clazz_t::DXFG_EVENT_QUOTE)))); @@ -148,7 +148,7 @@ void Quote::freeGraal(void *graalNative) { } if (static_cast(graalNative)->clazz != dxfg_event_clazz_t::DXFG_EVENT_QUOTE) { - throw std::invalid_argument( + throw InvalidArgumentException( fmt::format("Unable to free Quote's Graal data. Wrong event class {}! Expected: {}.", std::to_string(static_cast(static_cast(graalNative)->clazz)), std::to_string(static_cast(dxfg_event_clazz_t::DXFG_EVENT_QUOTE)))); diff --git a/src/event/market/SpreadOrder.cpp b/src/event/market/SpreadOrder.cpp index 4e517276e..bd7cd3a14 100644 --- a/src/event/market/SpreadOrder.cpp +++ b/src/event/market/SpreadOrder.cpp @@ -55,11 +55,11 @@ void SpreadOrder::freeGraalData(void *graalNative) noexcept { std::shared_ptr SpreadOrder::fromGraal(void *graalNative) { if (!graalNative) { - throw std::invalid_argument("Unable to create SpreadOrder. The `graalNative` parameter is nullptr"); + throw InvalidArgumentException("Unable to create SpreadOrder. The `graalNative` parameter is nullptr"); } if (static_cast(graalNative)->clazz != DXFG_EVENT_SPREAD_ORDER) { - throw std::invalid_argument( + throw InvalidArgumentException( fmt::format("Unable to create SpreadOrder. Wrong event class {}! Expected: {}.", std::to_string(static_cast(static_cast(graalNative)->clazz)), std::to_string(static_cast(dxfg_event_clazz_t::DXFG_EVENT_SPREAD_ORDER)))); @@ -94,7 +94,7 @@ void SpreadOrder::freeGraal(void *graalNative) { } if (static_cast(graalNative)->clazz != DXFG_EVENT_SPREAD_ORDER) { - throw std::invalid_argument( + throw InvalidArgumentException( fmt::format("Unable to free SpreadOrder's Graal data. Wrong event class {}! Expected: {}.", std::to_string(static_cast(static_cast(graalNative)->clazz)), std::to_string(static_cast(dxfg_event_clazz_t::DXFG_EVENT_SPREAD_ORDER)))); diff --git a/src/event/market/Summary.cpp b/src/event/market/Summary.cpp index 5ad82f3de..febfacc5b 100644 --- a/src/event/market/Summary.cpp +++ b/src/event/market/Summary.cpp @@ -67,11 +67,11 @@ void Summary::fillGraalData(void *graalNative) const noexcept { std::shared_ptr Summary::fromGraal(void *graalNative) { if (!graalNative) { - throw std::invalid_argument("Unable to create Summary. The `graalNative` parameter is nullptr"); + throw InvalidArgumentException("Unable to create Summary. The `graalNative` parameter is nullptr"); } if (static_cast(graalNative)->clazz != dxfg_event_clazz_t::DXFG_EVENT_SUMMARY) { - throw std::invalid_argument( + throw InvalidArgumentException( fmt::format("Unable to create Summary. Wrong event class {}! Expected: {}.", std::to_string(static_cast(static_cast(graalNative)->clazz)), std::to_string(static_cast(dxfg_event_clazz_t::DXFG_EVENT_SUMMARY)))); @@ -115,7 +115,7 @@ void Summary::freeGraal(void *graalNative) { } if (static_cast(graalNative)->clazz != dxfg_event_clazz_t::DXFG_EVENT_SUMMARY) { - throw std::invalid_argument( + throw InvalidArgumentException( fmt::format("Unable to free Summary's Graal data. Wrong event class {}! Expected: {}.", std::to_string(static_cast(static_cast(graalNative)->clazz)), std::to_string(static_cast(dxfg_event_clazz_t::DXFG_EVENT_SUMMARY)))); diff --git a/src/event/market/TimeAndSale.cpp b/src/event/market/TimeAndSale.cpp index 748befb55..6f7bd7521 100644 --- a/src/event/market/TimeAndSale.cpp +++ b/src/event/market/TimeAndSale.cpp @@ -89,11 +89,11 @@ void TimeAndSale::freeGraalData(void *graalNative) noexcept { std::shared_ptr TimeAndSale::fromGraal(void *graalNative) { if (!graalNative) { - throw std::invalid_argument("Unable to create TimeAndSale. The `graalNative` parameter is nullptr"); + throw InvalidArgumentException("Unable to create TimeAndSale. The `graalNative` parameter is nullptr"); } if (static_cast(graalNative)->clazz != dxfg_event_clazz_t::DXFG_EVENT_TIME_AND_SALE) { - throw std::invalid_argument( + throw InvalidArgumentException( fmt::format("Unable to create TimeAndSale. Wrong event class {}! Expected: {}.", std::to_string(static_cast(static_cast(graalNative)->clazz)), std::to_string(static_cast(dxfg_event_clazz_t::DXFG_EVENT_TIME_AND_SALE)))); @@ -139,7 +139,7 @@ void TimeAndSale::freeGraal(void *graalNative) { } if (static_cast(graalNative)->clazz != dxfg_event_clazz_t::DXFG_EVENT_TIME_AND_SALE) { - throw std::invalid_argument( + throw InvalidArgumentException( fmt::format("Unable to free TimeAndSale's Graal data. Wrong event class {}! Expected: {}.", std::to_string(static_cast(static_cast(graalNative)->clazz)), std::to_string(static_cast(dxfg_event_clazz_t::DXFG_EVENT_TIME_AND_SALE)))); diff --git a/src/event/market/Trade.cpp b/src/event/market/Trade.cpp index 7f1b297e9..67986ce72 100644 --- a/src/event/market/Trade.cpp +++ b/src/event/market/Trade.cpp @@ -42,11 +42,11 @@ void Trade::fillGraalData(void *graalNative) const noexcept { std::shared_ptr Trade::fromGraal(void *graalNative) { if (!graalNative) { - throw std::invalid_argument("Unable to create Trade. The `graalNative` parameter is nullptr"); + throw InvalidArgumentException("Unable to create Trade. The `graalNative` parameter is nullptr"); } if (static_cast(graalNative)->clazz != dxfg_event_clazz_t::DXFG_EVENT_TRADE) { - throw std::invalid_argument( + throw InvalidArgumentException( fmt::format("Unable to create Trade. Wrong event class {}! Expected: {}.", std::to_string(static_cast(static_cast(graalNative)->clazz)), std::to_string(static_cast(dxfg_event_clazz_t::DXFG_EVENT_TRADE)))); @@ -81,7 +81,7 @@ void Trade::freeGraal(void *graalNative) { } if (static_cast(graalNative)->clazz != dxfg_event_clazz_t::DXFG_EVENT_TRADE) { - throw std::invalid_argument( + throw InvalidArgumentException( fmt::format("Unable to free Trade's Graal data. Wrong event class {}! Expected: {}.", std::to_string(static_cast(static_cast(graalNative)->clazz)), std::to_string(static_cast(dxfg_event_clazz_t::DXFG_EVENT_TRADE)))); diff --git a/src/event/market/TradeETH.cpp b/src/event/market/TradeETH.cpp index f9104e2dc..f8fbb8dca 100644 --- a/src/event/market/TradeETH.cpp +++ b/src/event/market/TradeETH.cpp @@ -42,11 +42,11 @@ void TradeETH::fillGraalData(void *graalNative) const noexcept { std::shared_ptr TradeETH::fromGraal(void *graalNative) { if (!graalNative) { - throw std::invalid_argument("Unable to create TradeETH. The `graalNative` parameter is nullptr"); + throw InvalidArgumentException("Unable to create TradeETH. The `graalNative` parameter is nullptr"); } if (static_cast(graalNative)->clazz != dxfg_event_clazz_t::DXFG_EVENT_TRADE_ETH) { - throw std::invalid_argument( + throw InvalidArgumentException( fmt::format("Unable to create TradeETH. Wrong event class {}! Expected: {}.", std::to_string(static_cast(static_cast(graalNative)->clazz)), std::to_string(static_cast(dxfg_event_clazz_t::DXFG_EVENT_TRADE_ETH)))); @@ -81,7 +81,7 @@ void TradeETH::freeGraal(void *graalNative) { } if (static_cast(graalNative)->clazz != dxfg_event_clazz_t::DXFG_EVENT_TRADE_ETH) { - throw std::invalid_argument( + throw InvalidArgumentException( fmt::format("Unable to free TradeETH's Graal data. Wrong event class {}! Expected: {}.", std::to_string(static_cast(static_cast(graalNative)->clazz)), std::to_string(static_cast(dxfg_event_clazz_t::DXFG_EVENT_TRADE_ETH)))); diff --git a/src/event/misc/Message.cpp b/src/event/misc/Message.cpp index 5c0965ac1..9d2650a00 100644 --- a/src/event/misc/Message.cpp +++ b/src/event/misc/Message.cpp @@ -65,11 +65,11 @@ void Message::freeGraalData(void *graalNative) noexcept { std::shared_ptr Message::fromGraal(void *graalNative) { if (!graalNative) { - throw std::invalid_argument("Unable to create Message. The `graalNative` parameter is nullptr"); + throw InvalidArgumentException("Unable to create Message. The `graalNative` parameter is nullptr"); } if (static_cast(graalNative)->clazz != dxfg_event_clazz_t::DXFG_EVENT_MESSAGE) { - throw std::invalid_argument( + throw InvalidArgumentException( fmt::format("Unable to create Message. Wrong event class {}! Expected: {}.", std::to_string(static_cast(static_cast(graalNative)->clazz)), std::to_string(static_cast(dxfg_event_clazz_t::DXFG_EVENT_MESSAGE)))); @@ -100,7 +100,7 @@ void Message::freeGraal(void *graalNative) { } if (static_cast(graalNative)->clazz != dxfg_event_clazz_t::DXFG_EVENT_MESSAGE) { - throw std::invalid_argument( + throw InvalidArgumentException( fmt::format("Unable to free Message's Graal data. Wrong event class {}! Expected: {}.", std::to_string(static_cast(static_cast(graalNative)->clazz)), std::to_string(static_cast(dxfg_event_clazz_t::DXFG_EVENT_MESSAGE)))); diff --git a/src/event/option/Greeks.cpp b/src/event/option/Greeks.cpp index 220dafa4f..a51a7c05e 100644 --- a/src/event/option/Greeks.cpp +++ b/src/event/option/Greeks.cpp @@ -65,11 +65,11 @@ void Greeks::fillGraalData(void *graalNative) const noexcept { std::shared_ptr Greeks::fromGraal(void *graalNative) { if (!graalNative) { - throw std::invalid_argument("Unable to create Greeks. The `graalNative` parameter is nullptr"); + throw InvalidArgumentException("Unable to create Greeks. The `graalNative` parameter is nullptr"); } if (static_cast(graalNative)->clazz != dxfg_event_clazz_t::DXFG_EVENT_GREEKS) { - throw std::invalid_argument( + throw InvalidArgumentException( fmt::format("Unable to create Greeks. Wrong event class {}! Expected: {}.", std::to_string(static_cast(static_cast(graalNative)->clazz)), std::to_string(static_cast(dxfg_event_clazz_t::DXFG_EVENT_GREEKS)))); @@ -111,7 +111,7 @@ void Greeks::freeGraal(void *graalNative) { } if (static_cast(graalNative)->clazz != dxfg_event_clazz_t::DXFG_EVENT_GREEKS) { - throw std::invalid_argument( + throw InvalidArgumentException( fmt::format("Unable to free Greeks's Graal data. Wrong event class {}! Expected: {}.", std::to_string(static_cast(static_cast(graalNative)->clazz)), std::to_string(static_cast(dxfg_event_clazz_t::DXFG_EVENT_GREEKS)))); diff --git a/src/event/option/Series.cpp b/src/event/option/Series.cpp index 729039f18..e0be71656 100644 --- a/src/event/option/Series.cpp +++ b/src/event/option/Series.cpp @@ -69,11 +69,11 @@ void Series::fillGraalData(void *graalNative) const noexcept { std::shared_ptr Series::fromGraal(void *graalNative) { if (!graalNative) { - throw std::invalid_argument("Unable to create Series. The `graalNative` parameter is nullptr"); + throw InvalidArgumentException("Unable to create Series. The `graalNative` parameter is nullptr"); } if (static_cast(graalNative)->clazz != dxfg_event_clazz_t::DXFG_EVENT_SERIES) { - throw std::invalid_argument( + throw InvalidArgumentException( fmt::format("Unable to create Series. Wrong event class {}! Expected: {}.", std::to_string(static_cast(static_cast(graalNative)->clazz)), std::to_string(static_cast(dxfg_event_clazz_t::DXFG_EVENT_SERIES)))); @@ -115,7 +115,7 @@ void Series::freeGraal(void *graalNative) { } if (static_cast(graalNative)->clazz != dxfg_event_clazz_t::DXFG_EVENT_SERIES) { - throw std::invalid_argument( + throw InvalidArgumentException( fmt::format("Unable to free Series's Graal data. Wrong event class {}! Expected: {}.", std::to_string(static_cast(static_cast(graalNative)->clazz)), std::to_string(static_cast(dxfg_event_clazz_t::DXFG_EVENT_SERIES)))); diff --git a/src/event/option/TheoPrice.cpp b/src/event/option/TheoPrice.cpp index 408d63e8e..1e69b1810 100644 --- a/src/event/option/TheoPrice.cpp +++ b/src/event/option/TheoPrice.cpp @@ -63,11 +63,11 @@ void TheoPrice::fillGraalData(void *graalNative) const noexcept { std::shared_ptr TheoPrice::fromGraal(void *graalNative) { if (!graalNative) { - throw std::invalid_argument("Unable to create TheoPrice. The `graalNative` parameter is nullptr"); + throw InvalidArgumentException("Unable to create TheoPrice. The `graalNative` parameter is nullptr"); } if (static_cast(graalNative)->clazz != dxfg_event_clazz_t::DXFG_EVENT_THEO_PRICE) { - throw std::invalid_argument( + throw InvalidArgumentException( fmt::format("Unable to create TheoPrice. Wrong event class {}! Expected: {}.", std::to_string(static_cast(static_cast(graalNative)->clazz)), std::to_string(static_cast(dxfg_event_clazz_t::DXFG_EVENT_THEO_PRICE)))); @@ -108,7 +108,7 @@ void TheoPrice::freeGraal(void *graalNative) { } if (static_cast(graalNative)->clazz != dxfg_event_clazz_t::DXFG_EVENT_THEO_PRICE) { - throw std::invalid_argument( + throw InvalidArgumentException( fmt::format("Unable to free TheoPrice's Graal data. Wrong event class {}! Expected: {}.", std::to_string(static_cast(static_cast(graalNative)->clazz)), std::to_string(static_cast(dxfg_event_clazz_t::DXFG_EVENT_THEO_PRICE)))); diff --git a/src/event/option/Underlying.cpp b/src/event/option/Underlying.cpp index d509aaa02..00c2245b0 100644 --- a/src/event/option/Underlying.cpp +++ b/src/event/option/Underlying.cpp @@ -63,11 +63,11 @@ void Underlying::fillGraalData(void *graalNative) const noexcept { std::shared_ptr Underlying::fromGraal(void *graalNative) { if (!graalNative) { - throw std::invalid_argument("Unable to create Underlying. The `graalNative` parameter is nullptr"); + throw InvalidArgumentException("Unable to create Underlying. The `graalNative` parameter is nullptr"); } if (static_cast(graalNative)->clazz != dxfg_event_clazz_t::DXFG_EVENT_UNDERLYING) { - throw std::invalid_argument( + throw InvalidArgumentException( fmt::format("Unable to create Underlying. Wrong event class {}! Expected: {}.", std::to_string(static_cast(static_cast(graalNative)->clazz)), std::to_string(static_cast(dxfg_event_clazz_t::DXFG_EVENT_UNDERLYING)))); @@ -109,7 +109,7 @@ void Underlying::freeGraal(void *graalNative) { } if (static_cast(graalNative)->clazz != dxfg_event_clazz_t::DXFG_EVENT_UNDERLYING) { - throw std::invalid_argument( + throw InvalidArgumentException( fmt::format("Unable to free Underlying's Graal data. Wrong event class {}! Expected: {}.", std::to_string(static_cast(static_cast(graalNative)->clazz)), std::to_string(static_cast(dxfg_event_clazz_t::DXFG_EVENT_UNDERLYING)))); diff --git a/src/exceptions/InvalidArgumentException.cpp b/src/exceptions/InvalidArgumentException.cpp new file mode 100644 index 000000000..96575ef46 --- /dev/null +++ b/src/exceptions/InvalidArgumentException.cpp @@ -0,0 +1,16 @@ +// Copyright (c) 2024 Devexperts LLC. +// SPDX-License-Identifier: MPL-2.0 + +#include + +#include +#include + +DXFCPP_BEGIN_NAMESPACE + +InvalidArgumentException::InvalidArgumentException(const StringLikeWrapper &message, + const StringLikeWrapper &additionalStackTrace) + : RuntimeException(message, additionalStackTrace) { +} + +DXFCPP_END_NAMESPACE \ No newline at end of file diff --git a/src/internal/Common.cpp b/src/internal/Common.cpp index 3fd6b42ae..4852f0f76 100644 --- a/src/internal/Common.cpp +++ b/src/internal/Common.cpp @@ -5,3 +5,32 @@ #include #include + +DXFCPP_BEGIN_NAMESPACE + +namespace day_util { +std::int32_t getDayIdByYearMonthDay(std::int32_t year, std::int32_t month, std::int32_t day) { + if (month < 1 || month > 12) { + throw InvalidArgumentException("invalid month " + std::to_string(month)); + } + + std::int32_t dayOfYear = DAY_OF_YEAR[month] + day - 1; + + if (month > 2 && year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)) { + dayOfYear++; + } + + return year * 365 + math_util::div(year - 1, 4) - math_util::div(year - 1, 100) + math_util::div(year - 1, 400) + + dayOfYear - 719527; +} +} // namespace day_util + +namespace util { + +inline void throwInvalidChar(char c, const std::string &name) { + throw InvalidArgumentException("Invalid " + name + ": " + encodeChar(c)); +} + +} + +DXFCPP_END_NAMESPACE diff --git a/src/ipf/live/InstrumentProfileConnection.cpp b/src/ipf/live/InstrumentProfileConnection.cpp index be34bc180..dd2e420e3 100644 --- a/src/ipf/live/InstrumentProfileConnection.cpp +++ b/src/ipf/live/InstrumentProfileConnection.cpp @@ -66,7 +66,7 @@ InstrumentProfileConnection::createConnection(const std::string &address, std::shared_ptr connection(new InstrumentProfileConnection{}); if (!collector->handle_) { - throw std::invalid_argument("The collector's handle is invalid"); + throw InvalidArgumentException("The collector's handle is invalid"); } connection->id_ = diff --git a/src/isolated/api/IsolatedDXEndpoint.cpp b/src/isolated/api/IsolatedDXEndpoint.cpp index c2dd3aadf..c12140b88 100644 --- a/src/isolated/api/IsolatedDXEndpoint.cpp +++ b/src/isolated/api/IsolatedDXEndpoint.cpp @@ -13,7 +13,7 @@ namespace isolated::api::IsolatedDXEndpoint { void /* int32_t */ close(/* dxfg_endpoint_t* */ const JavaObjectHandle &endpoint) { if (!endpoint) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_DXEndpoint_close`. The `endpoint` handle is invalid"); } @@ -23,7 +23,7 @@ close(/* dxfg_endpoint_t* */ const JavaObjectHandle &endpoin void /* int32_t */ closeAndAwaitTermination(/* dxfg_endpoint_t* */ const JavaObjectHandle &endpoint) { if (!endpoint) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_DXEndpoint_closeAndAwaitTermination`. The `endpoint` handle is invalid"); } @@ -34,7 +34,7 @@ closeAndAwaitTermination(/* dxfg_endpoint_t* */ const JavaObjectHandle &endpoint, std::string_view user) { if (!endpoint) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_DXEndpoint_user`. The `endpoint` handle is invalid"); } @@ -45,7 +45,7 @@ void /* int32_t */ user(/* dxfg_endpoint_t* */ const JavaObjectHandle &endpoint, std::string_view password) { if (!endpoint) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_DXEndpoint_password`. The `endpoint` handle is invalid"); } @@ -55,7 +55,7 @@ void /* int32_t */ password(/* dxfg_endpoint_t* */ const JavaObjectHandle &endpoint, std::string_view address) { if (!endpoint) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_DXEndpoint_connect`. The `endpoint` handle is invalid"); } @@ -65,7 +65,7 @@ void connect(/* dxfg_endpoint_t* */ const JavaObjectHandle & void reconnect(/* dxfg_endpoint_t* */ const JavaObjectHandle &endpoint) { if (!endpoint) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_DXEndpoint_reconnect`. The `endpoint` handle is invalid"); } @@ -74,7 +74,7 @@ void reconnect(/* dxfg_endpoint_t* */ const JavaObjectHandle void disconnect(/* dxfg_endpoint_t* */ const JavaObjectHandle &endpoint) { if (!endpoint) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_DXEndpoint_disconnect`. The `endpoint` handle is invalid"); } @@ -83,7 +83,7 @@ void disconnect(/* dxfg_endpoint_t* */ const JavaObjectHandle &endpoint) { if (!endpoint) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_DXEndpoint_disconnectAndClear`. The `endpoint` handle is invalid"); } @@ -93,7 +93,7 @@ void disconnectAndClear(/* dxfg_endpoint_t* */ const JavaObjectHandle &endpoint) { if (!endpoint) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_DXEndpoint_awaitProcessed`. The `endpoint` handle is invalid"); } @@ -103,7 +103,7 @@ void awaitProcessed(/* dxfg_endpoint_t* */ const JavaObjectHandle &endpoint) { if (!endpoint) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_DXEndpoint_awaitNotConnected`. The `endpoint` handle is invalid"); } @@ -113,7 +113,7 @@ void awaitNotConnected(/* dxfg_endpoint_t* */ const JavaObjectHandle &endpoint) { if (!endpoint) { - throw std::invalid_argument("Unable to get state. The `endpoint` handle is invalid"); + throw InvalidArgumentException("Unable to get state. The `endpoint` handle is invalid"); } return graalStateToState(runGraalFunctionAndThrowIfLessThanZero(dxfg_DXEndpoint_getState, @@ -126,11 +126,11 @@ void addStateChangeListener( &listener) { if (!endpoint) { - throw std::invalid_argument("Unable to add DXEndpointStateChangeListener. The `endpoint` handle is invalid"); + throw InvalidArgumentException("Unable to add DXEndpointStateChangeListener. The `endpoint` handle is invalid"); } if (!listener) { - throw std::invalid_argument("Unable to add DXEndpointStateChangeListener. The `listener` handle is invalid"); + throw InvalidArgumentException("Unable to add DXEndpointStateChangeListener. The `listener` handle is invalid"); } runGraalFunctionAndThrowIfLessThanZero(dxfg_DXEndpoint_addStateChangeListener, @@ -144,11 +144,11 @@ void removeStateChangeListener( &listener) { if (!endpoint) { - throw std::invalid_argument("Unable to remove DXEndpointStateChangeListener. The `endpoint` handle is invalid"); + throw InvalidArgumentException("Unable to remove DXEndpointStateChangeListener. The `endpoint` handle is invalid"); } if (!listener) { - throw std::invalid_argument("Unable to remove DXEndpointStateChangeListener. The `listener` handle is invalid"); + throw InvalidArgumentException("Unable to remove DXEndpointStateChangeListener. The `listener` handle is invalid"); } runGraalFunctionAndThrowIfLessThanZero(dxfg_DXEndpoint_removeStateChangeListener, @@ -158,7 +158,7 @@ void removeStateChangeListener( void * /* dxfg_feed_t* */ getFeed(/* dxfg_endpoint_t * */ const JavaObjectHandle &endpoint) { if (!endpoint) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_DXEndpoint_getFeed`. The `endpoint` handle is invalid"); } @@ -169,7 +169,7 @@ void * /* dxfg_feed_t* */ getFeed(/* dxfg_endpoint_t * */ const JavaObjectHandle void * /* dxfg_publisher_t* */ getPublisher(/* dxfg_endpoint_t * */ const JavaObjectHandle &endpoint) { if (!endpoint) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_DXEndpoint_getPublisher`. The `endpoint` handle is invalid"); } @@ -180,7 +180,7 @@ getPublisher(/* dxfg_endpoint_t * */ const JavaObjectHandle /* dxfg_event_clazz_list_t* */ std::unordered_set getEventTypes(/* dxfg_endpoint_t * */ const JavaObjectHandle &endpoint) { if (!endpoint) { - throw std::invalid_argument("Unable to retrieve event types. The `endpoint` handle is invalid"); + throw InvalidArgumentException("Unable to retrieve event types. The `endpoint` handle is invalid"); } std::unordered_set result{}; @@ -233,7 +233,7 @@ void /* int32_t */ withRole(/* dxfg_endpoint_builder_t * */ const JavaObjectHandle &builder, /* dxfg_endpoint_role_t */ dxfcpp::DXEndpoint::Role role) { if (!builder) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_DXEndpoint_Builder_withRole`. The `builder` handle is invalid"); } @@ -246,7 +246,7 @@ void /* int32_t */ withProperty(/* dxfg_endpoint_builder_t * */ const JavaObjectHandle &builder, std::string_view key, std::string_view value) { if (!builder) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_DXEndpoint_Builder_withProperty`. The `builder` handle is invalid"); } @@ -260,7 +260,7 @@ void /* int32_t */ withProperties(/* dxfg_endpoint_builder_t * */ const JavaObjectHandle &builder, std::string_view filePath) { if (!builder) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_DXEndpoint_Builder_withProperties`. The `builder` handle is invalid"); } @@ -273,7 +273,7 @@ bool /* int32_t */ supportsProperty(/* dxfg_endpoint_builder_t * */ const JavaObjectHandle &builder, std::string_view key) { if (!builder) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_DXEndpoint_Builder_supportsProperty`. The `builder` handle is invalid"); } @@ -286,7 +286,7 @@ supportsProperty(/* dxfg_endpoint_builder_t * */ const JavaObjectHandle &builder) { if (!builder) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_DXEndpoint_Builder_build`. The `builder` handle is invalid"); } @@ -299,7 +299,7 @@ build(/* dxfg_endpoint_builder_t * */ const JavaObjectHandle create(void *userFunc, void *userData) { if (!userFunc) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to create DXEndpointStateChangeListener. The `userFunc` parameter is nullptr"); } diff --git a/src/isolated/api/IsolatedDXFeed.cpp b/src/isolated/api/IsolatedDXFeed.cpp index 1358bd752..34bb5ff5e 100644 --- a/src/isolated/api/IsolatedDXFeed.cpp +++ b/src/isolated/api/IsolatedDXFeed.cpp @@ -15,7 +15,7 @@ namespace isolated::api::IsolatedDXFeed { /* dxfg_symbol_t * */ const SymbolWrapper &symbol, std::int64_t fromTime, std::int64_t toTime) { if (!feed) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_DXFeed_getTimeSeriesPromise`. The `feed` handle is invalid"); } diff --git a/src/isolated/api/IsolatedDXFeedSubscription.cpp b/src/isolated/api/IsolatedDXFeedSubscription.cpp index 7424a7483..0a784cef3 100644 --- a/src/isolated/api/IsolatedDXFeedSubscription.cpp +++ b/src/isolated/api/IsolatedDXFeedSubscription.cpp @@ -18,7 +18,7 @@ create(/* dxfg_event_clazz_t */ const EventTypeEnum &eventType) { JavaObjectHandle /* dxfg_subscription_t* */ create(/* dxfg_event_clazz_list_t * */ const std::unique_ptr &eventClassList) { if (!eventClassList) { - throw std::invalid_argument("The eventClassList is nullptr"); + throw InvalidArgumentException("The eventClassList is nullptr"); } return JavaObjectHandle(runGraalFunctionAndThrowIfNullptr( @@ -27,7 +27,7 @@ create(/* dxfg_event_clazz_list_t * */ const std::unique_ptr &ev bool /* int32_t */ isClosed(/* dxfg_subscription_t * */ const JavaObjectHandle &sub) { if (!sub) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_DXFeedSubscription_isClosed`. The `sub` handle is invalid"); } @@ -37,7 +37,7 @@ bool /* int32_t */ isClosed(/* dxfg_subscription_t * */ const JavaObjectHandle &sub) { if (!sub) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_DXFeedSubscription_close`. The `sub` handle is invalid"); } @@ -47,7 +47,7 @@ void /* int32_t */ close(/* dxfg_subscription_t * */ const JavaObjectHandle &sub) { if (!sub) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_DXFeedSubscription_clear`. The `sub` handle is invalid"); } @@ -58,7 +58,7 @@ void /* int32_t */ clear(/* dxfg_subscription_t * */ const JavaObjectHandle /* dxfg_symbol_list* */ getSymbols(/* dxfg_subscription_t * */ const JavaObjectHandle &sub) { if (!sub) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_DXFeedSubscription_getSymbols`. The `sub` handle is invalid"); } @@ -75,7 +75,7 @@ getSymbols(/* dxfg_subscription_t * */ const JavaObjectHandle /* dxfg_symbol_list* */ getDecoratedSymbols(/* dxfg_subscription_t * */ const JavaObjectHandle &sub) { if (!sub) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_DXFeedSubscription_getDecoratedSymbols`. The `sub` handle is invalid"); } @@ -92,12 +92,12 @@ getDecoratedSymbols(/* dxfg_subscription_t * */ const JavaObjectHandle &sub, /* dxfg_symbol_list * */ void *symbols) { if (!sub) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_DXFeedSubscription_setSymbols`. The `sub` handle is invalid"); } if (!symbols) { - throw std::invalid_argument("Unable to execute function `dxfg_DXFeedSubscription_setSymbols`. The " + throw InvalidArgumentException("Unable to execute function `dxfg_DXFeedSubscription_setSymbols`. The " "`symbols` is nullptr"); } @@ -109,12 +109,12 @@ void /* int32_t */ setSymbols(/* dxfg_subscription_t * */ const JavaObjectHandle void /* int32_t */ addSymbol(/* dxfg_subscription_t * */ const JavaObjectHandle &sub, /* dxfg_symbol_t * */ void *symbol) { if (!sub) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_DXFeedSubscription_addSymbol`. The `sub` handle is invalid"); } if (!symbol) { - throw std::invalid_argument("Unable to execute function `dxfg_DXFeedSubscription_addSymbol`. The " + throw InvalidArgumentException("Unable to execute function `dxfg_DXFeedSubscription_addSymbol`. The " "`symbol` is nullptr"); } @@ -126,12 +126,12 @@ void /* int32_t */ addSymbol(/* dxfg_subscription_t * */ const JavaObjectHandle< void /* int32_t */ addSymbols(/* dxfg_subscription_t * */ const JavaObjectHandle &sub, /* dxfg_symbol_list * */ void *symbols) { if (!sub) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_DXFeedSubscription_addSymbols`. The `sub` handle is invalid"); } if (!symbols) { - throw std::invalid_argument("Unable to execute function `dxfg_DXFeedSubscription_addSymbols`. The " + throw InvalidArgumentException("Unable to execute function `dxfg_DXFeedSubscription_addSymbols`. The " "`symbols` is nullptr"); } @@ -143,12 +143,12 @@ void /* int32_t */ addSymbols(/* dxfg_subscription_t * */ const JavaObjectHandle void /* int32_t */ removeSymbol(/* dxfg_subscription_t * */ const JavaObjectHandle &sub, /* dxfg_symbol_t * */ void *symbol) { if (!sub) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_DXFeedSubscription_removeSymbol`. The `sub` handle is invalid"); } if (!symbol) { - throw std::invalid_argument("Unable to execute function `dxfg_DXFeedSubscription_removeSymbol`. The " + throw InvalidArgumentException("Unable to execute function `dxfg_DXFeedSubscription_removeSymbol`. The " "`symbol` is nullptr"); } @@ -160,12 +160,12 @@ void /* int32_t */ removeSymbol(/* dxfg_subscription_t * */ const JavaObjectHand void /* int32_t */ removeSymbols(/* dxfg_subscription_t * */ const JavaObjectHandle &sub, /* dxfg_symbol_list * */ void *symbols) { if (!sub) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_DXFeedSubscription_removeSymbols`. The `sub` handle is invalid"); } if (!symbols) { - throw std::invalid_argument("Unable to execute function `dxfg_DXFeedSubscription_removeSymbols`. The " + throw InvalidArgumentException("Unable to execute function `dxfg_DXFeedSubscription_removeSymbols`. The " "`symbols` is nullptr"); } @@ -177,7 +177,7 @@ void /* int32_t */ removeSymbols(/* dxfg_subscription_t * */ const JavaObjectHan /* dxfg_time_period_t* */ JavaObjectHandle getAggregationPeriod(/* dxfg_subscription_t * */ const JavaObjectHandle &sub) { if (!sub) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_DXFeedSubscription_getAggregationPeriod`. The `sub` handle is invalid"); } @@ -188,12 +188,12 @@ getAggregationPeriod(/* dxfg_subscription_t * */ const JavaObjectHandle &sub, /* dxfg_time_period_t * */ const JavaObjectHandle &period) { if (!sub) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_DXFeedSubscription_setAggregationPeriod`. The `sub` handle is invalid"); } if (!period) { - throw std::invalid_argument("Unable to execute function `dxfg_DXFeedSubscription_setAggregationPeriod`. The " + throw InvalidArgumentException("Unable to execute function `dxfg_DXFeedSubscription_setAggregationPeriod`. The " "`period` handle is invalid"); } @@ -206,12 +206,12 @@ void /* int32_t */ addEventListener(/* dxfg_subscription_t * */ const JavaObjectHandle &sub, /* dxfg_feed_event_listener_t * */ const JavaObjectHandle &listener) { if (!sub) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_DXFeedSubscription_addEventListener`. The `sub` handle is invalid"); } if (!listener) { - throw std::invalid_argument("Unable to execute function `dxfg_DXFeedSubscription_addEventListener`. The " + throw InvalidArgumentException("Unable to execute function `dxfg_DXFeedSubscription_addEventListener`. The " "`listener` handle is invalid"); } @@ -225,12 +225,12 @@ void /* int32_t */ addChangeListener( /* dxfg_observable_subscription_change_listener_t * */ const JavaObjectHandle &listener) { if (!sub) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_DXFeedSubscription_addChangeListener`. The `sub` handle is invalid"); } if (!listener) { - throw std::invalid_argument("Unable to execute function `dxfg_DXFeedSubscription_addChangeListener`. The " + throw InvalidArgumentException("Unable to execute function `dxfg_DXFeedSubscription_addChangeListener`. The " "`listener` handle is invalid"); } @@ -244,12 +244,12 @@ void /* int32_t */ removeChangeListener( /* dxfg_observable_subscription_change_listener_t * */ const JavaObjectHandle &listener) { if (!sub) { - throw std::invalid_argument("Unable to execute function `dxfg_DXFeedSubscription_removeChangeListener`. " + throw InvalidArgumentException("Unable to execute function `dxfg_DXFeedSubscription_removeChangeListener`. " "The `sub` handle is invalid"); } if (!listener) { - throw std::invalid_argument("Unable to execute function `dxfg_DXFeedSubscription_removeChangeListener`. The " + throw InvalidArgumentException("Unable to execute function `dxfg_DXFeedSubscription_removeChangeListener`. The " "`listener` handle is invalid"); } @@ -260,7 +260,7 @@ void /* int32_t */ removeChangeListener( std::int32_t getEventsBatchLimit(/* dxfg_subscription_t * */ const JavaObjectHandle &sub) { if (!sub) { - throw std::invalid_argument("Unable to execute function `dxfg_DXFeedSubscription_getEventsBatchLimit`. " + throw InvalidArgumentException("Unable to execute function `dxfg_DXFeedSubscription_getEventsBatchLimit`. " "The `sub` handle is invalid"); } @@ -271,7 +271,7 @@ std::int32_t getEventsBatchLimit(/* dxfg_subscription_t * */ const JavaObjectHan /* int32_t */ void setEventsBatchLimit(/* dxfg_subscription_t * */ const JavaObjectHandle &sub, std::int32_t eventsBatchLimit) { if (!sub) { - throw std::invalid_argument("Unable to execute function `dxfg_DXFeedSubscription_setEventsBatchLimit`. " + throw InvalidArgumentException("Unable to execute function `dxfg_DXFeedSubscription_setEventsBatchLimit`. " "The `sub` handle is invalid"); } @@ -284,7 +284,7 @@ namespace DXFeedEventListener { JavaObjectHandle /* dxfg_feed_event_listener_t* */ create(/* dxfg_feed_event_listener_function */ void *userFunc, void *userData) { if (!userFunc) { - throw std::invalid_argument("Unable to create DXFeedEventListener. The `userFunc` parameter is nullptr"); + throw InvalidArgumentException("Unable to create DXFeedEventListener. The `userFunc` parameter is nullptr"); } return JavaObjectHandle(runGraalFunctionAndThrowIfNullptr( diff --git a/src/isolated/api/IsolatedDXPublisher.cpp b/src/isolated/api/IsolatedDXPublisher.cpp index 76139e832..bb01e17be 100644 --- a/src/isolated/api/IsolatedDXPublisher.cpp +++ b/src/isolated/api/IsolatedDXPublisher.cpp @@ -14,12 +14,12 @@ namespace isolated::api::IsolatedDXPublisher { void /* int32_t */ publishEvents(/* dxfg_publisher_t * */ const JavaObjectHandle &publisher, /* dxfg_event_type_list * */ void *events) { if (!publisher) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_DXPublisher_publishEvents`. The `publisher` handle is invalid"); } if (!events) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_DXPublisher_publishEvents`. The `events` is nullptr"); } @@ -32,7 +32,7 @@ JavaObjectHandle /* dxfg_observable_subscript getSubscription(/* dxfg_publisher_t * */ const JavaObjectHandle &publisher, /* dxfg_event_clazz_t */ const EventTypeEnum &eventType) { if (!publisher) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_DXPublisher_getSubscription`. The `publisher` handle is invalid"); } diff --git a/src/isolated/api/IsolatedDXPublisherObservableSubscription.cpp b/src/isolated/api/IsolatedDXPublisherObservableSubscription.cpp index 6a3cc3b49..116b9c7bb 100644 --- a/src/isolated/api/IsolatedDXPublisherObservableSubscription.cpp +++ b/src/isolated/api/IsolatedDXPublisherObservableSubscription.cpp @@ -13,7 +13,7 @@ namespace isolated::api::IsolatedDXPublisherObservableSubscription { bool /* int32_t */ isClosed(/* dxfg_observable_subscription_t * */ const JavaObjectHandle &sub) { if (!sub) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_ObservableSubscription_isClosed`. The `sub` handle is invalid"); } @@ -24,7 +24,7 @@ isClosed(/* dxfg_observable_subscription_t * */ const JavaObjectHandle /* dxfg_event_clazz_list_t* */ getEventTypes( /* dxfg_observable_subscription_t * */ const JavaObjectHandle &sub) { if (!sub) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_ObservableSubscription_getEventTypes`. The `sub` handle is invalid"); } @@ -53,7 +53,7 @@ bool /* int32_t */ containsEventType( /* dxfg_observable_subscription_t * */ const JavaObjectHandle &sub, /* dxfg_event_clazz_t */ const EventTypeEnum &eventType) { if (!sub) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_ObservableSubscription_containsEventType`. The `sub` handle is invalid"); } @@ -67,12 +67,12 @@ void /* int32_t */ addChangeListener( /* dxfg_observable_subscription_change_listener_t * */ const JavaObjectHandle &listener) { if (!sub) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_ObservableSubscription_addChangeListener`. The `sub` handle is invalid"); } if (!listener) { - throw std::invalid_argument("Unable to execute function `dxfg_ObservableSubscription_addChangeListener`. The " + throw InvalidArgumentException("Unable to execute function `dxfg_ObservableSubscription_addChangeListener`. The " "`listener` handle is invalid"); } @@ -86,12 +86,12 @@ void /* int32_t */ removeChangeListener( /* dxfg_observable_subscription_change_listener_t * */ const JavaObjectHandle &listener) { if (!sub) { - throw std::invalid_argument("Unable to execute function `dxfg_ObservableSubscription_removeChangeListener`. " + throw InvalidArgumentException("Unable to execute function `dxfg_ObservableSubscription_removeChangeListener`. " "The `sub` handle is invalid"); } if (!listener) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_ObservableSubscription_removeChangeListener`. The " "`listener` handle is invalid"); } diff --git a/src/isolated/api/osub/IsolatedObservableSubscriptionChangeListener.cpp b/src/isolated/api/osub/IsolatedObservableSubscriptionChangeListener.cpp index 45b2f7352..2853efcc4 100644 --- a/src/isolated/api/osub/IsolatedObservableSubscriptionChangeListener.cpp +++ b/src/isolated/api/osub/IsolatedObservableSubscriptionChangeListener.cpp @@ -16,17 +16,17 @@ create(/* dxfg_ObservableSubscriptionChangeListener_function_symbolsAdded */ voi /* dxfg_ObservableSubscriptionChangeListener_function_subscriptionClosed */ void *functionSubscriptionClosed, void *userData) { if (!functionSymbolsAdded) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to create ObservableSubscriptionChangeListener. The `functionSymbolsAdded` parameter is nullptr"); } if (!functionSymbolsRemoved) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to create ObservableSubscriptionChangeListener. The `functionSymbolsRemoved` parameter is nullptr"); } if (!functionSubscriptionClosed) { - throw std::invalid_argument("Unable to create ObservableSubscriptionChangeListener. The " + throw InvalidArgumentException("Unable to create ObservableSubscriptionChangeListener. The " "`functionSubscriptionClosed` parameter is nullptr"); } diff --git a/src/isolated/auth/IsolatedAuthToken.cpp b/src/isolated/auth/IsolatedAuthToken.cpp index c678e1971..b07b49ea9 100644 --- a/src/isolated/auth/IsolatedAuthToken.cpp +++ b/src/isolated/auth/IsolatedAuthToken.cpp @@ -65,7 +65,7 @@ createCustomToken(/* const char* */ const StringLikeWrapper &scheme, /* const char* */ std::string getHttpAuthorization(/* dxfg_auth_token_t* */ const JavaObjectHandle &authToken) { if (!authToken) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_AuthToken_getHttpAuthorization`. The `authToken` handle is invalid"); } @@ -81,7 +81,7 @@ getHttpAuthorization(/* dxfg_auth_token_t* */ const JavaObjectHandle /// dxfg_AuthToken_getUser /* const char* */ std::string getUser(/* dxfg_auth_token_t* */ const JavaObjectHandle &authToken) { if (!authToken) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_AuthToken_getUser`. The `authToken` handle is invalid"); } @@ -97,7 +97,7 @@ getHttpAuthorization(/* dxfg_auth_token_t* */ const JavaObjectHandle /// dxfg_AuthToken_getPassword /* const char* */ std::string getPassword(/* dxfg_auth_token_t* */ const JavaObjectHandle &authToken) { if (!authToken) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_AuthToken_getPassword`. The `authToken` handle is invalid"); } @@ -113,7 +113,7 @@ getHttpAuthorization(/* dxfg_auth_token_t* */ const JavaObjectHandle /// dxfg_AuthToken_getScheme /* const char* */ std::string getScheme(/* dxfg_auth_token_t* */ const JavaObjectHandle &authToken) { if (!authToken) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_AuthToken_getScheme`. The `authToken` handle is invalid"); } @@ -129,7 +129,7 @@ getHttpAuthorization(/* dxfg_auth_token_t* */ const JavaObjectHandle /// dxfg_AuthToken_getValue /* const char* */ std::string getValue(/* dxfg_auth_token_t* */ const JavaObjectHandle &authToken) { if (!authToken) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_AuthToken_getValue`. The `authToken` handle is invalid"); } diff --git a/src/isolated/internal/IsolatedObject.cpp b/src/isolated/internal/IsolatedObject.cpp index 516cf81a6..543451820 100644 --- a/src/isolated/internal/IsolatedObject.cpp +++ b/src/isolated/internal/IsolatedObject.cpp @@ -15,7 +15,7 @@ namespace IsolatedObject { /// dxfg_Object_toString /* const char* */ std::string toString(/* dxfg_java_object_handler* */ void *object) { if (!object) { - throw std::invalid_argument("Unable to execute function `dxfg_Object_toString`. The `object` is null"); + throw InvalidArgumentException("Unable to execute function `dxfg_Object_toString`. The `object` is null"); } auto value = @@ -30,11 +30,11 @@ namespace IsolatedObject { /// dxfg_Object_equals std::int32_t equals(/* dxfg_java_object_handler* */ void *object, /* dxfg_java_object_handler* */ void *other) { if (!object) { - throw std::invalid_argument("Unable to execute function `dxfg_Object_equals`. The `object` is null"); + throw InvalidArgumentException("Unable to execute function `dxfg_Object_equals`. The `object` is null"); } if (!other) { - throw std::invalid_argument("Unable to execute function `dxfg_Object_equals`. The `other` is null"); + throw InvalidArgumentException("Unable to execute function `dxfg_Object_equals`. The `other` is null"); } return runGraalFunctionAndThrowIfMinusMin(dxfg_Object_equals, static_cast(object), @@ -44,7 +44,7 @@ std::int32_t equals(/* dxfg_java_object_handler* */ void *object, /* dxfg_java_o /// dxfg_Object_hashCode /* int32_t */ std::size_t hashCode(/* dxfg_java_object_handler* */ void *object) { if (!object) { - throw std::invalid_argument("Unable to execute function `dxfg_Object_hashCode`. The `object` is null"); + throw InvalidArgumentException("Unable to execute function `dxfg_Object_hashCode`. The `object` is null"); } return static_cast( diff --git a/src/isolated/internal/IsolatedString.cpp b/src/isolated/internal/IsolatedString.cpp index 418af0e42..9f6bcf4c0 100644 --- a/src/isolated/internal/IsolatedString.cpp +++ b/src/isolated/internal/IsolatedString.cpp @@ -14,7 +14,7 @@ namespace IsolatedString { bool release(const char *string) { if (!string) { - throw std::invalid_argument("Unable to execute function `dxfg_String_release`. The `string` is nullptr"); + throw InvalidArgumentException("Unable to execute function `dxfg_String_release`. The `string` is nullptr"); } return runGraalFunctionAndThrowIfLessThanZero(dxfg_String_release, string) == 0; @@ -30,7 +30,7 @@ namespace IsolatedStringList { bool release(/* dxfg_string_list* */ void *stringList) { if (!stringList) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_CList_String_release`. The `stringList` is nullptr"); } diff --git a/src/isolated/internal/IsolatedTimeFormat.cpp b/src/isolated/internal/IsolatedTimeFormat.cpp index e09ccdb7e..8a087b07c 100644 --- a/src/isolated/internal/IsolatedTimeFormat.cpp +++ b/src/isolated/internal/IsolatedTimeFormat.cpp @@ -24,7 +24,7 @@ namespace IsolatedTimeFormat { /* dxfg_time_format_t* */ JavaObjectHandle withTimeZone(/* dxfg_time_format_t* */ const JavaObjectHandle &timeFormat) { if (!timeFormat) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_TimeFormat_withTimeZone`. The `timeFormat` handle is invalid"); } @@ -35,7 +35,7 @@ withTimeZone(/* dxfg_time_format_t* */ const JavaObjectHandle withMillis(/* dxfg_time_format_t* */ const JavaObjectHandle &timeFormat) { if (!timeFormat) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_TimeFormat_withMillis`. The `timeFormat` handle is invalid"); } @@ -46,7 +46,7 @@ withMillis(/* dxfg_time_format_t* */ const JavaObjectHandle std::int64_t parse(/* dxfg_time_format_t* */ const JavaObjectHandle &timeFormat, std::string_view value) { if (!timeFormat) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_TimeFormat_parse`. The `timeFormat` handle is invalid"); } @@ -57,7 +57,7 @@ std::int64_t parse(/* dxfg_time_format_t* */ const JavaObjectHandle &timeFormat, std::int64_t value) { if (!timeFormat) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_TimeFormat_format`. The `timeFormat` handle is invalid"); } diff --git a/src/isolated/ipf/IsolatedInstrumentProfile.cpp b/src/isolated/ipf/IsolatedInstrumentProfile.cpp index c59859c09..46e6de71c 100644 --- a/src/isolated/ipf/IsolatedInstrumentProfile.cpp +++ b/src/isolated/ipf/IsolatedInstrumentProfile.cpp @@ -20,7 +20,7 @@ namespace isolated::ipf::IsolatedInstrumentProfile { /* dxfg_instrument_profile_t* */ JavaObjectHandle create(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_new2`. The ip handle is invalid"); } @@ -31,7 +31,7 @@ create(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_getType`. The ip handle is invalid"); } @@ -46,7 +46,7 @@ create(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip, const StringLikeWrapper &value) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_setType`. The ip handle is invalid"); } @@ -58,7 +58,7 @@ create(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_getSymbol`. The ip handle is invalid"); } @@ -73,7 +73,7 @@ getSymbol(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip, const StringLikeWrapper &value) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_setSymbol`. The ip handle is invalid"); } @@ -85,7 +85,7 @@ getSymbol(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_getDescription`. The ip handle is invalid"); } @@ -100,7 +100,7 @@ getDescription(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip, const StringLikeWrapper &value) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_setDescription`. The ip handle is invalid"); } @@ -112,7 +112,7 @@ getDescription(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_getLocalSymbol`. The ip handle is invalid"); } @@ -127,7 +127,7 @@ getLocalSymbol(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip, const StringLikeWrapper &value) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_setLocalSymbol`. The ip handle is invalid"); } @@ -139,7 +139,7 @@ getLocalSymbol(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_getLocalDescription`. The ip handle is invalid"); } @@ -155,7 +155,7 @@ getLocalDescription(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip, const StringLikeWrapper &value) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_setLocalDescription`. The ip handle is invalid"); } @@ -167,7 +167,7 @@ setLocalDescription(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_getCountry`. The ip handle is invalid"); } @@ -182,7 +182,7 @@ getCountry(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip, const StringLikeWrapper &value) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_setCountry`. The ip handle is invalid"); } @@ -193,7 +193,7 @@ getCountry(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_getOPOL`. The ip handle is invalid"); } @@ -208,7 +208,7 @@ getCountry(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip, const StringLikeWrapper &value) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_setOPOL`. The ip handle is invalid"); } @@ -220,7 +220,7 @@ getCountry(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_getExchangeData`. The ip handle is invalid"); } @@ -235,7 +235,7 @@ getExchangeData(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip, const StringLikeWrapper &value) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_setExchangeData`. The ip handle is invalid"); } @@ -247,7 +247,7 @@ getExchangeData(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_getExchanges`. The ip handle is invalid"); } @@ -262,7 +262,7 @@ getExchanges(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip, const StringLikeWrapper &value) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_setExchanges`. The ip handle is invalid"); } @@ -274,7 +274,7 @@ getExchanges(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_getCurrency`. The ip handle is invalid"); } @@ -289,7 +289,7 @@ getCurrency(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip, const StringLikeWrapper &value) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_setCurrency`. The ip handle is invalid"); } @@ -301,7 +301,7 @@ getCurrency(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_getBaseCurrency`. The ip handle is invalid"); } @@ -316,7 +316,7 @@ getBaseCurrency(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip, const StringLikeWrapper &value) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_setBaseCurrency`. The ip handle is invalid"); } @@ -327,7 +327,7 @@ getBaseCurrency(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_getCFI`. The ip handle is invalid"); } @@ -342,7 +342,7 @@ getBaseCurrency(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip, const StringLikeWrapper &value) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_setCFI`. The ip handle is invalid"); } @@ -353,7 +353,7 @@ getBaseCurrency(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_getISIN`. The ip handle is invalid"); } @@ -368,7 +368,7 @@ getBaseCurrency(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip, const StringLikeWrapper &value) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_setISIN`. The ip handle is invalid"); } @@ -379,7 +379,7 @@ getBaseCurrency(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_getSEDOL`. The ip handle is invalid"); } @@ -394,7 +394,7 @@ getBaseCurrency(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip, const StringLikeWrapper &value) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_setSEDOL`. The ip handle is invalid"); } @@ -405,7 +405,7 @@ getBaseCurrency(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_getCUSIP`. The ip handle is invalid"); } @@ -420,7 +420,7 @@ getBaseCurrency(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip, const StringLikeWrapper &value) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_setCUSIP`. The ip handle is invalid"); } @@ -431,7 +431,7 @@ getBaseCurrency(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_getICB`. The ip handle is invalid"); } @@ -443,7 +443,7 @@ std::int32_t getICB(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip, std::int32_t value) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_setICB`. The ip handle is invalid"); } @@ -454,7 +454,7 @@ std::int32_t getICB(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_getSIC`. The ip handle is invalid"); } @@ -466,7 +466,7 @@ std::int32_t getSIC(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip, std::int32_t value) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_setSIC`. The ip handle is invalid"); } @@ -477,7 +477,7 @@ std::int32_t getSIC(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_getMultiplier`. The ip handle is invalid"); } @@ -489,7 +489,7 @@ double getMultiplier(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip, double value) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_setMultiplier`. The ip handle is invalid"); } @@ -501,7 +501,7 @@ double getMultiplier(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_getProduct`. The ip handle is invalid"); } @@ -516,7 +516,7 @@ getProduct(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip, const StringLikeWrapper &value) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_setProduct`. The ip handle is invalid"); } @@ -528,7 +528,7 @@ getProduct(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_getUnderlying`. The ip handle is invalid"); } @@ -543,7 +543,7 @@ getUnderlying(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip, const StringLikeWrapper &value) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_setUnderlying`. The ip handle is invalid"); } @@ -554,7 +554,7 @@ getUnderlying(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_getSPC`. The ip handle is invalid"); } @@ -566,7 +566,7 @@ double getSPC(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip, double value) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_setSPC`. The ip handle is invalid"); } @@ -578,7 +578,7 @@ double getSPC(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_getAdditionalUnderlyings`. The ip handle is invalid"); } @@ -594,7 +594,7 @@ getAdditionalUnderlyings(/* dxfg_instrument_profile_t* */ const JavaObjectHandle setAdditionalUnderlyings(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip, const StringLikeWrapper &value) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_setAdditionalUnderlyings`. The ip handle is invalid"); } @@ -605,7 +605,7 @@ setAdditionalUnderlyings(/* dxfg_instrument_profile_t* */ const JavaObjectHandle // dxfg_InstrumentProfile_getMMY /* const char* */ std::string getMMY(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_getMMY`. The ip handle is invalid"); } @@ -620,7 +620,7 @@ setAdditionalUnderlyings(/* dxfg_instrument_profile_t* */ const JavaObjectHandle /* std::int32_t */ void setMMY(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip, const StringLikeWrapper &value) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_setMMY`. The ip handle is invalid"); } @@ -631,7 +631,7 @@ setAdditionalUnderlyings(/* dxfg_instrument_profile_t* */ const JavaObjectHandle // dxfg_InstrumentProfile_getExpiration std::int32_t getExpiration(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_getExpiration`. The ip handle is invalid"); } @@ -643,7 +643,7 @@ std::int32_t getExpiration(/* dxfg_instrument_profile_t* */ const JavaObjectHand /* std::int32_t */ void setExpiration(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip, std::int32_t value) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_setExpiration`. The ip handle is invalid"); } @@ -654,7 +654,7 @@ std::int32_t getExpiration(/* dxfg_instrument_profile_t* */ const JavaObjectHand // dxfg_InstrumentProfile_getLastTrade std::int32_t getLastTrade(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_getLastTrade`. The ip handle is invalid"); } @@ -666,7 +666,7 @@ std::int32_t getLastTrade(/* dxfg_instrument_profile_t* */ const JavaObjectHandl /* std::int32_t */ void setLastTrade(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip, std::int32_t value) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_setLastTrade`. The ip handle is invalid"); } @@ -677,7 +677,7 @@ std::int32_t getLastTrade(/* dxfg_instrument_profile_t* */ const JavaObjectHandl // dxfg_InstrumentProfile_getStrike double getStrike(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_getStrike`. The ip handle is invalid"); } @@ -689,7 +689,7 @@ double getStrike(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip, double value) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_setStrike`. The ip handle is invalid"); } @@ -701,7 +701,7 @@ double getStrike(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_getOptionType`. The ip handle is invalid"); } @@ -716,7 +716,7 @@ getOptionType(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip, const StringLikeWrapper &value) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_setOptionType`. The ip handle is invalid"); } @@ -728,7 +728,7 @@ getOptionType(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_getExpirationStyle`. The ip handle is invalid"); } @@ -744,7 +744,7 @@ getExpirationStyle(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip, const StringLikeWrapper &value) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_setExpirationStyle`. The ip handle is invalid"); } @@ -756,7 +756,7 @@ setExpirationStyle(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_getSettlementStyle`. The ip handle is invalid"); } @@ -772,7 +772,7 @@ getSettlementStyle(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip, const StringLikeWrapper &value) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_setSettlementStyle`. The ip handle is invalid"); } @@ -784,7 +784,7 @@ setSettlementStyle(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_getPriceIncrements`. The ip handle is invalid"); } @@ -800,7 +800,7 @@ getPriceIncrements(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip, const StringLikeWrapper &value) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_setPriceIncrements`. The ip handle is invalid"); } @@ -812,7 +812,7 @@ setPriceIncrements(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_getTradingHours`. The ip handle is invalid"); } @@ -827,7 +827,7 @@ getTradingHours(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip, const StringLikeWrapper &value) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_setTradingHours`. The ip handle is invalid"); } @@ -839,7 +839,7 @@ getTradingHours(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip, const StringLikeWrapper &name) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_getField`. The ip handle is invalid"); } @@ -854,7 +854,7 @@ getTradingHours(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip, const StringLikeWrapper &name, const StringLikeWrapper &value) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_setField`. The ip handle is invalid"); } @@ -866,7 +866,7 @@ getTradingHours(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip, const StringLikeWrapper &name) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_getNumericField`. The ip handle is invalid"); } @@ -878,7 +878,7 @@ double getNumericField(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip, const StringLikeWrapper &name, double value) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_setNumericField`. The ip handle is invalid"); } @@ -890,7 +890,7 @@ double getNumericField(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip, const StringLikeWrapper &name) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_getDateField`. The ip handle is invalid"); } @@ -902,7 +902,7 @@ std::int32_t getDateField(/* dxfg_instrument_profile_t* */ const JavaObjectHandl /* std::int32_t */ void setDateField(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip, const StringLikeWrapper &name, std::int32_t value) { if (!ip) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfile_setNumericField`. The ip handle is invalid"); } @@ -914,7 +914,7 @@ std::int32_t getDateField(/* dxfg_instrument_profile_t* */ const JavaObjectHandl /* dxfg_string_list* */ std::vector getNonEmptyCustomFieldNames(/* dxfg_instrument_profile_t* */ const JavaObjectHandle &ip) { if (!ip) { - throw std::invalid_argument("Unable to execute function `dxfg_InstrumentProfile_getNonEmptyCustomFieldNames`. " + throw InvalidArgumentException("Unable to execute function `dxfg_InstrumentProfile_getNonEmptyCustomFieldNames`. " "The ip handle is invalid"); } @@ -941,7 +941,7 @@ getNonEmptyCustomFieldNames(/* dxfg_instrument_profile_t* */ const JavaObjectHan namespace isolated::ipf::IsolatedInstrumentProfileList { void release(/* dxfg_instrument_profile_list * */ void *list) { if (!list) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_CList_InstrumentProfile_wrapper_release`. The list is nullptr"); } @@ -951,7 +951,7 @@ void release(/* dxfg_instrument_profile_list * */ void *list) { void releaseWrapper(/* dxfg_instrument_profile_list * */ void *list) { if (!list) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_CList_InstrumentProfile_wrapper_release`. The list is nullptr"); } diff --git a/src/isolated/ipf/IsolatedInstrumentProfileReader.cpp b/src/isolated/ipf/IsolatedInstrumentProfileReader.cpp index 807c57405..60aebb72f 100644 --- a/src/isolated/ipf/IsolatedInstrumentProfileReader.cpp +++ b/src/isolated/ipf/IsolatedInstrumentProfileReader.cpp @@ -19,7 +19,7 @@ namespace isolated::ipf::IsolatedInstrumentProfileReader { std::int64_t getLastModified( /* dxfg_instrument_profile_reader_t * */ const JavaObjectHandle &handle) { if (!handle) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfileReader_getLastModified`. The handle is invalid"); } @@ -30,7 +30,7 @@ std::int64_t getLastModified( bool wasComplete( /* dxfg_instrument_profile_reader_t * */ const JavaObjectHandle &handle) { if (!handle) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfileReader_wasComplete`. The handle is invalid"); } @@ -42,7 +42,7 @@ bool wasComplete( readFromFile(/* dxfg_instrument_profile_reader_t * */ const JavaObjectHandle &handle, const StringLikeWrapper &address) { if (!handle) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfileReader_readFromFile`. The handle is invalid"); } @@ -55,7 +55,7 @@ readFromFile(/* dxfg_instrument_profile_reader_t * */ const JavaObjectHandle &handle, const StringLikeWrapper &address, const StringLikeWrapper &user, const StringLikeWrapper &password) { if (!handle) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfileReader_readFromFile`. The handle is invalid"); } @@ -69,12 +69,12 @@ readFromFile(/* dxfg_instrument_profile_reader_t * */ const JavaObjectHandle &handle, const StringLikeWrapper &address, const JavaObjectHandle &token) { if (!handle) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfileReader_readFromFile`. The handle is invalid"); } if (!token) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_InstrumentProfileReader_readFromFile3`. The token is invalid"); } diff --git a/src/isolated/promise/IsolatedPromise.cpp b/src/isolated/promise/IsolatedPromise.cpp index b88776ab2..92836e758 100644 --- a/src/isolated/promise/IsolatedPromise.cpp +++ b/src/isolated/promise/IsolatedPromise.cpp @@ -13,7 +13,7 @@ namespace isolated::promise::IsolatedPromise { bool /* int32_t */ isDone(/* dxfg_promise_t * */ void *promise) { if (!promise) { - throw std::invalid_argument("Unable to execute function `dxfg_Promise_isDone`. The `promise` is nullptr"); + throw InvalidArgumentException("Unable to execute function `dxfg_Promise_isDone`. The `promise` is nullptr"); } return runGraalFunctionAndThrowIfLessThanZero(dxfg_Promise_isDone, static_cast(promise)) == 1; @@ -21,7 +21,7 @@ bool /* int32_t */ isDone(/* dxfg_promise_t * */ void *promise) { bool /* int32_t */ hasResult(/* dxfg_promise_t * */ void *promise) { if (!promise) { - throw std::invalid_argument("Unable to execute function `dxfg_Promise_hasResult`. The `promise` is nullptr"); + throw InvalidArgumentException("Unable to execute function `dxfg_Promise_hasResult`. The `promise` is nullptr"); } return runGraalFunctionAndThrowIfLessThanZero(dxfg_Promise_hasResult, static_cast(promise)) == 1; @@ -29,7 +29,7 @@ bool /* int32_t */ hasResult(/* dxfg_promise_t * */ void *promise) { bool /* int32_t */ hasException(/* dxfg_promise_t * */ void *promise) { if (!promise) { - throw std::invalid_argument("Unable to execute function `dxfg_Promise_hasException`. The `promise` is nullptr"); + throw InvalidArgumentException("Unable to execute function `dxfg_Promise_hasException`. The `promise` is nullptr"); } return runGraalFunctionAndThrowIfLessThanZero(dxfg_Promise_hasException, static_cast(promise)) == @@ -38,7 +38,7 @@ bool /* int32_t */ hasException(/* dxfg_promise_t * */ void *promise) { bool /* int32_t */ isCancelled(/* dxfg_promise_t * */ void *promise) { if (!promise) { - throw std::invalid_argument("Unable to execute function `dxfg_Promise_isCancelled`. The `promise` is nullptr"); + throw InvalidArgumentException("Unable to execute function `dxfg_Promise_isCancelled`. The `promise` is nullptr"); } return runGraalFunctionAndThrowIfLessThanZero(dxfg_Promise_isCancelled, static_cast(promise)) == @@ -47,7 +47,7 @@ bool /* int32_t */ isCancelled(/* dxfg_promise_t * */ void *promise) { std::shared_ptr /* dxfg_event_type_t* */ getResult(/* dxfg_promise_event_t * */ void *promise) { if (!promise) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_Promise_EventType_getResult`. The `promise` is nullptr"); } @@ -64,7 +64,7 @@ std::shared_ptr /* dxfg_event_type_t* */ getResult(/* dxfg_promise_ev std::vector> /* dxfg_event_type_list* */ getResults(/* dxfg_promise_events_t * */ void *promise) { if (!promise) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_Promise_List_EventType_getResult`. The `promise` is nullptr"); } @@ -80,7 +80,7 @@ getResults(/* dxfg_promise_events_t * */ void *promise) { JavaException /* dxfg_exception_t* */ getException(/* dxfg_promise_t * */ void *promise) { if (!promise) { - throw std::invalid_argument("Unable to execute function `dxfg_Promise_getException`. The `promise` is nullptr"); + throw InvalidArgumentException("Unable to execute function `dxfg_Promise_getException`. The `promise` is nullptr"); } auto *graalException = @@ -95,7 +95,7 @@ JavaException /* dxfg_exception_t* */ getException(/* dxfg_promise_t * */ void * void /* int32_t */ await(/* dxfg_promise_t * */ void *promise) { if (!promise) { - throw std::invalid_argument("Unable to execute function `dxfg_Promise_await`. The `promise` is nullptr"); + throw InvalidArgumentException("Unable to execute function `dxfg_Promise_await`. The `promise` is nullptr"); } runGraalFunctionAndThrowIfLessThanZero(dxfg_Promise_await, static_cast(promise)); @@ -103,7 +103,7 @@ void /* int32_t */ await(/* dxfg_promise_t * */ void *promise) { void /* int32_t */ await(/* dxfg_promise_t * */ void *promise, std::int32_t timeoutInMilliseconds) { if (!promise) { - throw std::invalid_argument("Unable to execute function `dxfg_Promise_await2`. The `promise` is nullptr"); + throw InvalidArgumentException("Unable to execute function `dxfg_Promise_await2`. The `promise` is nullptr"); } runGraalFunctionAndThrowIfLessThanZero(dxfg_Promise_await2, static_cast(promise), @@ -112,7 +112,7 @@ void /* int32_t */ await(/* dxfg_promise_t * */ void *promise, std::int32_t time bool /* int32_t */ awaitWithoutException(/* dxfg_promise_t * */ void *promise, std::int32_t timeoutInMilliseconds) { if (!promise) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_Promise_awaitWithoutException`. The `promise` is nullptr"); } @@ -122,7 +122,7 @@ bool /* int32_t */ awaitWithoutException(/* dxfg_promise_t * */ void *promise, s void /* int32_t */ cancel(/* dxfg_promise_t * */ void *promise) { if (!promise) { - throw std::invalid_argument("Unable to execute function `dxfg_Promise_cancel`. The `promise` is nullptr"); + throw InvalidArgumentException("Unable to execute function `dxfg_Promise_cancel`. The `promise` is nullptr"); } runGraalFunctionAndThrowIfLessThanZero(dxfg_Promise_cancel, static_cast(promise)); diff --git a/src/isolated/util/IsolatedTimePeriod.cpp b/src/isolated/util/IsolatedTimePeriod.cpp index 4aa3d3f0d..5e7e374d5 100644 --- a/src/isolated/util/IsolatedTimePeriod.cpp +++ b/src/isolated/util/IsolatedTimePeriod.cpp @@ -27,7 +27,7 @@ namespace isolated::util::IsolatedTimePeriod { std::int64_t getTime(/* dxfg_time_period_t* */ const JavaObjectHandle &timePeriod) { if (!timePeriod) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_TimePeriod_getTime`. The `timePeriod` handle is invalid"); } @@ -37,7 +37,7 @@ std::int64_t getTime(/* dxfg_time_period_t* */ const JavaObjectHandle &timePeriod) { if (!timePeriod) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_TimePeriod_getSeconds`. The `timePeriod` handle is invalid"); } @@ -47,7 +47,7 @@ std::int32_t getSeconds(/* dxfg_time_period_t* */ const JavaObjectHandle &timePeriod) { if (!timePeriod) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to execute function `dxfg_TimePeriod_getNanos`. The `timePeriod` handle is invalid"); } diff --git a/src/ondemand/OnDemandService.cpp b/src/ondemand/OnDemandService.cpp index 94a02f9c9..e25c2fb8c 100644 --- a/src/ondemand/OnDemandService.cpp +++ b/src/ondemand/OnDemandService.cpp @@ -40,7 +40,7 @@ std::shared_ptr OnDemandService::getInstance(std::shared_ptr onDemandService{new OnDemandService{}}; if (!endpoint->handle_) { - throw std::invalid_argument("The endpoint's handle is invalid"); + throw InvalidArgumentException("The endpoint's handle is invalid"); } auto id = ApiContext::getInstance()->getManager()->registerEntity(onDemandService); diff --git a/src/schedule/Day.cpp b/src/schedule/Day.cpp index 2ef773775..1dd363869 100644 --- a/src/schedule/Day.cpp +++ b/src/schedule/Day.cpp @@ -14,7 +14,7 @@ Day::Day(void *handle) noexcept : handle_(handle) { Day::Ptr Day::create(void *handle) { if (!handle) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to create a Day object. The handle is nullptr"); } diff --git a/src/schedule/Schedule.cpp b/src/schedule/Schedule.cpp index 4459ce80b..58fa561e3 100644 --- a/src/schedule/Schedule.cpp +++ b/src/schedule/Schedule.cpp @@ -13,7 +13,7 @@ Schedule::Schedule(void *handle) noexcept : handle_(handle) { Schedule::Ptr Schedule::create(void *handle) { if (!handle) { - throw std::invalid_argument("Unable to create a Schedule object. The handle is nullptr"); + throw InvalidArgumentException("Unable to create a Schedule object. The handle is nullptr"); } return std::shared_ptr(new Schedule(handle)); @@ -21,7 +21,7 @@ Schedule::Ptr Schedule::create(void *handle) { Schedule::Ptr Schedule::getInstance(std::shared_ptr profile) { if (!profile) { - throw std::invalid_argument("The profile is nullptr"); + throw InvalidArgumentException("The profile is nullptr"); } auto schedule = create(isolated::schedule::Schedule::getInstance(profile->handle_.get())); @@ -35,7 +35,7 @@ Schedule::Ptr Schedule::getInstance(const std::string &scheduleDefinition) { Schedule::Ptr Schedule::getInstance(std::shared_ptr profile, const std::string &venue) { if (!profile) { - throw std::invalid_argument("The profile is nullptr"); + throw InvalidArgumentException("The profile is nullptr"); } auto schedule = create(isolated::schedule::Schedule::getInstance(profile->handle_.get(), venue)); @@ -45,7 +45,7 @@ Schedule::Ptr Schedule::getInstance(std::shared_ptr profile, std::vector Schedule::getTradingVenues(std::shared_ptr profile) { if (!profile) { - throw std::invalid_argument("The profile is nullptr"); + throw InvalidArgumentException("The profile is nullptr"); } auto result = isolated::schedule::Schedule::getTradingVenues(profile->handle_.get()); diff --git a/src/schedule/Session.cpp b/src/schedule/Session.cpp index 58b296446..e4455130e 100644 --- a/src/schedule/Session.cpp +++ b/src/schedule/Session.cpp @@ -13,7 +13,7 @@ Session::Session(void *handle) noexcept : handle_(handle) { Session::Ptr Session::create(void *handle) { if (!handle) { - throw std::invalid_argument( + throw InvalidArgumentException( "Unable to create a Session object. The handle is nullptr"); } diff --git a/src/symbols/StringSymbol.cpp b/src/symbols/StringSymbol.cpp index dc8e2a224..0fb86ee37 100644 --- a/src/symbols/StringSymbol.cpp +++ b/src/symbols/StringSymbol.cpp @@ -72,7 +72,7 @@ StringSymbol StringSymbol::fromGraal(void *graalNative) { } if (graalNative == nullptr) { - throw std::invalid_argument("Unable to create StringSymbol. The `graalNative` parameter is nullptr"); + throw InvalidArgumentException("Unable to create StringSymbol. The `graalNative` parameter is nullptr"); } auto *graalSymbol = static_cast(graalNative); diff --git a/src/symbols/SymbolWrapper.cpp b/src/symbols/SymbolWrapper.cpp index 192b72e1e..0c7df0fa5 100644 --- a/src/symbols/SymbolWrapper.cpp +++ b/src/symbols/SymbolWrapper.cpp @@ -178,7 +178,7 @@ SymbolWrapper SymbolWrapper::fromGraal(void *graalNative) { } if (graalNative == nullptr) { - throw std::invalid_argument("Unable to create SymbolWrapper. The `graalNative` parameter is nullptr"); + throw InvalidArgumentException("Unable to create SymbolWrapper. The `graalNative` parameter is nullptr"); } switch (static_cast(graalNative)->type) { @@ -198,7 +198,7 @@ SymbolWrapper SymbolWrapper::fromGraal(void *graalNative) { return TimeSeriesSubscriptionSymbol::fromGraal(graalNative); default: - throw std::runtime_error(fmt::format("Unable to create SymbolWrapper. Unknown symbol type: {}", + throw RuntimeException(fmt::format("Unable to create SymbolWrapper. Unknown symbol type: {}", static_cast(static_cast(graalNative)->type))); } From 87ebbf8f92580af1257625869ddf959f56c6eb79 Mon Sep 17 00:00:00 2001 From: ttldtor Date: Wed, 24 Jul 2024 17:16:39 +0300 Subject: [PATCH 4/7] [MDAPI-113] [C++][Tools] Tools should report invalid event type fix CandleSymbolTest --- include/dxfeed_graal_cpp_api/internal/Common.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/dxfeed_graal_cpp_api/internal/Common.hpp b/include/dxfeed_graal_cpp_api/internal/Common.hpp index c9e306711..e0db3213b 100644 --- a/include/dxfeed_graal_cpp_api/internal/Common.hpp +++ b/include/dxfeed_graal_cpp_api/internal/Common.hpp @@ -742,7 +742,7 @@ struct StringLikeWrapper { if (auto sv = std::get_if(&data_); sv) { auto sv2 = sv->substr(pos, count); - return {sv2.data(), sv->size()}; + return {sv2.data(), sv2.size()}; } else { return std::get(data_).substr(pos, count); } From c64a959f3dc80ad8206ef406976bd4526fe52876 Mon Sep 17 00:00:00 2001 From: ttldtor Date: Wed, 24 Jul 2024 18:36:54 +0300 Subject: [PATCH 5/7] [MDAPI-113] [C++][Tools] Tools should report invalid event type Check the types parsing. --- .../internal/utils/CmdArgsUtils.hpp | 22 ++++---- .../internal/utils/StringUtils.hpp | 10 ++-- src/internal/utils/CmdArgsUtils.cpp | 52 ++++++++++-------- tools/Tools/src/Connect/ConnectTool.hpp | 55 ++++++++++++------- tools/Tools/src/Dump/DumpTool.hpp | 22 ++++++-- .../Tools/src/LatencyTest/LatencyTestTool.hpp | 21 ++++++- tools/Tools/src/PerfTest/PerfTestTool.hpp | 23 ++++++-- 7 files changed, 136 insertions(+), 69 deletions(-) diff --git a/include/dxfeed_graal_cpp_api/internal/utils/CmdArgsUtils.hpp b/include/dxfeed_graal_cpp_api/internal/utils/CmdArgsUtils.hpp index fc9c89ad1..b693505ad 100644 --- a/include/dxfeed_graal_cpp_api/internal/utils/CmdArgsUtils.hpp +++ b/include/dxfeed_graal_cpp_api/internal/utils/CmdArgsUtils.hpp @@ -107,10 +107,10 @@ struct DXFCPP_EXPORT CmdArgsUtils final { * "all" or "*" will be converted to all types. * * @param types The comma-separated list of event types. - * @return The created set of parsed types. + * @return The created pair of set of parsed types and vector unknown types. */ - static std::unordered_set> - parseTypes(const std::string &types) noexcept; + static std::pair>, std::vector> + parseTypes(const std::string &types); /** * Parses an input string and returns a set of event types. @@ -118,9 +118,10 @@ struct DXFCPP_EXPORT CmdArgsUtils final { * "all" or "*" will be converted to all types. * * @param types The comma-separated list of event types. - * @return The created set of parsed types. + * @return The created pair of set of parsed types and vector unknown types. */ - static std::unordered_set> parseTypes(const char *types) noexcept { + static std::pair>, std::vector> + parseTypes(const char *types) { return parseTypes(std::string(types)); } @@ -130,9 +131,10 @@ struct DXFCPP_EXPORT CmdArgsUtils final { * "all" or "*" will be converted to all types. * * @param types The comma-separated list of event types. - * @return The created set of parsed types. + * @return The created pair of set of parsed types and vector unknown types. */ - static std::unordered_set> parseTypes(std::string_view types) noexcept { + static std::pair>, std::vector> + parseTypes(std::string_view types) { return parseTypes(types.data()); } @@ -142,10 +144,10 @@ struct DXFCPP_EXPORT CmdArgsUtils final { * "all" or "*" will be converted to all types. * * @param types The comma-separated list of event types. - * @return The created set of parsed types. + * @return The created pair of set of parsed types and vector unknown types. */ - static std::unordered_set> - parseTypes(std::optional types) noexcept; + static std::pair>, std::vector> + parseTypes(std::optional types); /** * Parses the input collection of strings and returns a collection of key-value properties. diff --git a/include/dxfeed_graal_cpp_api/internal/utils/StringUtils.hpp b/include/dxfeed_graal_cpp_api/internal/utils/StringUtils.hpp index a3ad6b9c4..8a8c3867d 100644 --- a/include/dxfeed_graal_cpp_api/internal/utils/StringUtils.hpp +++ b/include/dxfeed_graal_cpp_api/internal/utils/StringUtils.hpp @@ -217,14 +217,16 @@ std::string namesToString(It begin, It end) { return result + "]"; } -template std::string elementsToString(It begin, It end) { - std::string result{"["}; +template +std::string elementsToString(It begin, It end, const std::string &prefix = "[", const std::string &postfix = "[", + const std::string &separator = ", ") { + std::string result{prefix}; for (auto it = begin; it != end; it++) { - result += String::EMPTY + toStringAny(*it) + (std::next(it) == end ? "" : ", "); + result += String::EMPTY + toStringAny(*it) + (std::next(it) == end ? "" : separator); } - return result + "]"; + return result + postfix; } DXFCPP_EXPORT std::string encodeChar(std::int16_t c); diff --git a/src/internal/utils/CmdArgsUtils.cpp b/src/internal/utils/CmdArgsUtils.cpp index bed73cb00..d13803c87 100644 --- a/src/internal/utils/CmdArgsUtils.cpp +++ b/src/internal/utils/CmdArgsUtils.cpp @@ -55,13 +55,17 @@ auto splitAndTrim = [](auto &&symbols, char sep = ',') noexcept { return symbols | ranges::views::split(sep) | filterNonEmpty | transformToString | trim; }; -decltype(ranges::views::transform([](auto &&s) { +auto toUpper = [](auto&& s) { auto locale = std::locale{}; return s | ranges::views::transform([&locale](auto c) { return std::toupper(c, locale); }) | ranges::to(); +}; + +decltype(ranges::views::transform([](auto &&s) { + return toUpper(s); })) transformToUpper{}; std::unordered_set parseStringSymbols(const std::string &symbols) noexcept { @@ -171,8 +175,8 @@ std::unordered_set CmdArgsUtils::parseCandleSymbols(std::optional< return {}; } -std::unordered_set> -CmdArgsUtils::parseTypes(const std::string &types) noexcept { +std::pair>, std::vector> +CmdArgsUtils::parseTypes(const std::string &types) { auto trimmedTypes = trimStr(types); if (trimmedTypes.empty()) { @@ -180,34 +184,36 @@ CmdArgsUtils::parseTypes(const std::string &types) noexcept { } if (trimmedTypes == "*" || trimmedTypes == "all" || trimmedTypes == "All" || trimmedTypes == "ALL") { - return EventTypeEnum::ALL | ranges::to>>(); + return {EventTypeEnum::ALL | ranges::to>>(), {}}; } - auto split = splitAndTrim(trimmedTypes) | filterNonEmpty; - auto allByName = split | transformToUpper | ranges::views::filter([](const auto &s) { - return EventTypeEnum::ALL_BY_NAME.contains(s); - }) | - ranges::views::transform([](const auto &s) { - return EventTypeEnum::ALL_BY_NAME.at(s); - }); - auto allByClassName = split | ranges::views::filter([](const auto &s) { - return EventTypeEnum::ALL_BY_CLASS_NAME.contains(s); - }) | - ranges::views::transform([](const auto &s) { - return EventTypeEnum::ALL_BY_CLASS_NAME.at(s); - }); - - return ranges::views::concat(allByName, allByClassName) | - ranges::to>>(); + auto split = splitAndTrim(trimmedTypes) | filterNonEmpty | ranges::to>; + + std::unordered_set> result; + std::vector unknown; + + for (auto t : split) { + auto u = toUpper(t); + + if (EventTypeEnum::ALL_BY_NAME.contains(u)) { + result.emplace(EventTypeEnum::ALL_BY_NAME.at(u)); + } else if (EventTypeEnum::ALL_BY_CLASS_NAME.contains(t)) { + result.emplace(EventTypeEnum::ALL_BY_CLASS_NAME.at(t)); + } else { + unknown.push_back(t); + } + } + + return {result, unknown}; } -std::unordered_set> -CmdArgsUtils::parseTypes(std::optional types) noexcept { +std::pair>, std::vector> +CmdArgsUtils::parseTypes(std::optional types) { if (types.has_value()) { return parseTypes(types.value()); } - return std::unordered_set>{}; + return {}; } std::unordered_map CmdArgsUtils::parseProperties(const std::string &properties) noexcept { diff --git a/tools/Tools/src/Connect/ConnectTool.hpp b/tools/Tools/src/Connect/ConnectTool.hpp index 00dbc0af6..a63788ab3 100644 --- a/tools/Tools/src/Connect/ConnectTool.hpp +++ b/tools/Tools/src/Connect/ConnectTool.hpp @@ -152,14 +152,45 @@ struct ConnectTool { System::setProperties(parsedProperties); + auto [parsedTypes, unknownTypes] = CmdArgsUtils::parseTypes(args.types); + + if (!unknownTypes.empty()) { + auto unknown = elementsToString(unknownTypes.begin(), unknownTypes.end(), "", ""); + + throw InvalidArgumentException( + fmt::format("There are unknown event types: {}!\n List of available event types: {}", unknown, + enum_utils::getEventTypeEnumClassNamesList(", "))); + } + + if (parsedTypes.empty()) { + throw InvalidArgumentException("The resulting list of types is empty!"); + } + + auto parsedSymbols = CmdArgsUtils::parseSymbols(args.symbols); + + if (args.fromTime.has_value()) { + auto fromTime = TimeFormat::DEFAULT.parse(args.fromTime.value()); + + parsedSymbols = parsedSymbols | ranges::views::transform([fromTime](const auto &sw) { + return TimeSeriesSubscriptionSymbol{sw, fromTime}; + }) | + ranges::to>; + } else if (args.source.has_value()) { + auto source = OrderSource::valueOf(args.source.value()); + + parsedSymbols = parsedSymbols | ranges::views::transform([source](const auto &sw) { + return IndexedEventSubscriptionSymbol{sw, source}; + }) | + ranges::to>; + } + auto endpoint = DXEndpoint::newBuilder() ->withRole(args.forceStream ? DXEndpoint::Role::STREAM_FEED : DXEndpoint::Role::FEED) ->withProperties(parsedProperties) ->withName(NAME + "Tool-Feed") ->build(); - std::shared_ptr sub = - endpoint->getFeed()->createSubscription(CmdArgsUtils::parseTypes(args.types)); + std::shared_ptr sub = endpoint->getFeed()->createSubscription(parsedTypes); if (!args.isQuite) { sub->addEventListener([](auto &&events) { @@ -171,24 +202,6 @@ struct ConnectTool { }); } - auto symbols = CmdArgsUtils::parseSymbols(args.symbols); - - if (args.fromTime.has_value()) { - auto fromTime = TimeFormat::DEFAULT.parse(args.fromTime.value()); - - symbols = symbols | ranges::views::transform([fromTime](const auto &sw) { - return TimeSeriesSubscriptionSymbol{sw, fromTime}; - }) | - ranges::to>; - } else if (args.source.has_value()) { - auto source = OrderSource::valueOf(args.source.value()); - - symbols = symbols | ranges::views::transform([source](const auto &sw) { - return IndexedEventSubscriptionSymbol{sw, source}; - }) | - ranges::to>; - } - if (args.tape.has_value()) { std::string tape = args.tape.value(); @@ -206,7 +219,7 @@ struct ConnectTool { }); } - sub->addSymbols(symbols); + sub->addSymbols(parsedSymbols); endpoint->connect(args.address); std::this_thread::sleep_for(std::chrono::days(365)); } catch (const RuntimeException &e) { diff --git a/tools/Tools/src/Dump/DumpTool.hpp b/tools/Tools/src/Dump/DumpTool.hpp index 088da526f..7501e3d62 100644 --- a/tools/Tools/src/Dump/DumpTool.hpp +++ b/tools/Tools/src/Dump/DumpTool.hpp @@ -133,6 +133,22 @@ struct DumpTool { System::setProperties(parsedProperties); + auto [parsedTypes, unknownTypes] = CmdArgsUtils::parseTypes(args.types.has_value() ? *args.types : "all"); + + if (!unknownTypes.empty()) { + auto unknown = elementsToString(unknownTypes.begin(), unknownTypes.end(), "", ""); + + throw InvalidArgumentException( + fmt::format("There are unknown event types: {}!\n List of available event types: {}", unknown, + enum_utils::getEventTypeEnumClassNamesList(", "))); + } + + if (parsedTypes.empty()) { + throw InvalidArgumentException("The resulting list of types is empty!"); + } + + auto parsedSymbols = CmdArgsUtils::parseSymbols(args.symbols.has_value() ? *args.symbols : "all"); + auto inputEndpoint = DXEndpoint::newBuilder() ->withRole(DXEndpoint::Role::STREAM_FEED) @@ -141,8 +157,7 @@ struct DumpTool { ->withName(NAME + "Tool-Feed") ->build(); - auto sub = inputEndpoint->getFeed()->createSubscription( - !args.types.has_value() ? CmdArgsUtils::parseTypes("all") : CmdArgsUtils::parseTypes(*args.types)); + auto sub = inputEndpoint->getFeed()->createSubscription(parsedTypes); if (!args.isQuite) { sub->addEventListener([](auto &&events) { @@ -173,8 +188,7 @@ struct DumpTool { }); } - sub->addSymbols(!args.symbols.has_value() ? CmdArgsUtils::parseSymbols("all") - : CmdArgsUtils::parseSymbols(args.symbols.value())); + sub->addSymbols(parsedSymbols); inputEndpoint->connect(args.address); inputEndpoint->awaitNotConnected(); diff --git a/tools/Tools/src/LatencyTest/LatencyTestTool.hpp b/tools/Tools/src/LatencyTest/LatencyTestTool.hpp index a45097f12..d360f0392 100644 --- a/tools/Tools/src/LatencyTest/LatencyTestTool.hpp +++ b/tools/Tools/src/LatencyTest/LatencyTestTool.hpp @@ -346,6 +346,22 @@ struct LatencyTest { System::setProperties(parsedProperties); + auto [parsedTypes, unknownTypes] = CmdArgsUtils::parseTypes(args.types.has_value() ? *args.types : "all"); + + if (!unknownTypes.empty()) { + auto unknown = elementsToString(unknownTypes.begin(), unknownTypes.end(), "", ""); + + throw InvalidArgumentException( + fmt::format("There are unknown event types: {}!\n List of available event types: {}", unknown, + enum_utils::getEventTypeEnumClassNamesList(", "))); + } + + if (parsedTypes.empty()) { + throw InvalidArgumentException("The resulting list of types is empty!"); + } + + auto parsedSymbols = CmdArgsUtils::parseSymbols(args.symbols.has_value() ? *args.symbols : "all"); + auto endpoint = DXEndpoint::newBuilder() ->withRole(args.forceStream ? DXEndpoint::Role::STREAM_FEED : DXEndpoint::Role::FEED) @@ -354,8 +370,7 @@ struct LatencyTest { ->withName(NAME + "Tool-Feed") ->build(); - auto sub = endpoint->getFeed()->createSubscription( - CmdArgsUtils::parseTypes(args.types.has_value() ? *args.types : "all")); + auto sub = endpoint->getFeed()->createSubscription(parsedTypes); auto diagnostic = Diagnostic::create(std::chrono::seconds(args.interval)); sub->addEventListener([d = diagnostic](auto &&events) { @@ -363,7 +378,7 @@ struct LatencyTest { d->handleEvents(events); }); - sub->addSymbols(CmdArgsUtils::parseSymbols(args.symbols.has_value() ? *args.symbols : "all")); + sub->addSymbols(parsedSymbols); endpoint->connect(args.address); endpoint->awaitNotConnected(); endpoint->closeAndAwaitTermination(); diff --git a/tools/Tools/src/PerfTest/PerfTestTool.hpp b/tools/Tools/src/PerfTest/PerfTestTool.hpp index dcbe28a5b..cd5485913 100644 --- a/tools/Tools/src/PerfTest/PerfTestTool.hpp +++ b/tools/Tools/src/PerfTest/PerfTestTool.hpp @@ -133,8 +133,7 @@ struct PerfTestTool { } public: - static std::shared_ptr create(std::chrono::seconds measurementPeriod, - bool showCpuUsageByCore) { + static std::shared_ptr create(std::chrono::seconds measurementPeriod, bool showCpuUsageByCore) { auto d = std::shared_ptr(new Diagnostic(showCpuUsageByCore)); d->timer_ = Timer::schedule( @@ -241,6 +240,22 @@ struct PerfTestTool { System::setProperties(parsedProperties); + auto [parsedTypes, unknownTypes] = CmdArgsUtils::parseTypes(args.types); + + if (!unknownTypes.empty()) { + auto unknown = elementsToString(unknownTypes.begin(), unknownTypes.end(), "", ""); + + throw InvalidArgumentException( + fmt::format("There are unknown event types: {}!\n List of available event types: {}", unknown, + enum_utils::getEventTypeEnumClassNamesList(", "))); + } + + if (parsedTypes.empty()) { + throw InvalidArgumentException("The resulting list of types is empty!"); + } + + auto parsedSymbols = CmdArgsUtils::parseSymbols(args.symbols); + auto endpoint = DXEndpoint::newBuilder() ->withRole(args.forceStream ? DXEndpoint::Role::STREAM_FEED : DXEndpoint::Role::FEED) @@ -249,7 +264,7 @@ struct PerfTestTool { ->withName(NAME + "Tool-Feed") ->build(); - auto sub = endpoint->getFeed()->createSubscription(CmdArgsUtils::parseTypes(args.types)); + auto sub = endpoint->getFeed()->createSubscription(parsedTypes); auto diagnostic = Diagnostic::create(2s, args.showCpuUsageByCore); std::atomic hash{}; @@ -265,7 +280,7 @@ struct PerfTestTool { }); } - sub->addSymbols(CmdArgsUtils::parseSymbols(args.symbols)); + sub->addSymbols(parsedSymbols); endpoint->connect(args.address); endpoint->awaitNotConnected(); endpoint->closeAndAwaitTermination(); From aa23c5c54de0c0f6b25f31c3dbe6e83657ff7eb0 Mon Sep 17 00:00:00 2001 From: ttldtor Date: Wed, 24 Jul 2024 18:45:50 +0300 Subject: [PATCH 6/7] [MDAPI-113] [C++][Tools] Tools should report invalid event type ReleaseNotes --- ReleaseNotes.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ReleaseNotes.md b/ReleaseNotes.md index e4f1e1536..ac329d786 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -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: From 0911cef4b0f5479e7e53eb253ae39a9980f60ae0 Mon Sep 17 00:00:00 2001 From: ttldtor Date: Wed, 24 Jul 2024 18:59:09 +0300 Subject: [PATCH 7/7] [MDAPI-113] [C++][Tools] Tools should report invalid event type Fix samples build --- samples/cpp/DxFeedConnect/src/main.cpp | 2 +- samples/cpp/DxFeedFileParser/src/main.cpp | 2 +- samples/cpp/DxFeedIpfConnect/src/main.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/samples/cpp/DxFeedConnect/src/main.cpp b/samples/cpp/DxFeedConnect/src/main.cpp index e42a6ab79..00df8ce5a 100644 --- a/samples/cpp/DxFeedConnect/src/main.cpp +++ b/samples/cpp/DxFeedConnect/src/main.cpp @@ -70,7 +70,7 @@ int main(int argc, char *argv[]) { auto endpoint = DXEndpoint::create()->connect(address); // Create a subscription with specified types attached to feed. - auto sub = endpoint->getFeed()->createSubscription(types); + auto sub = endpoint->getFeed()->createSubscription(types.first); // Add an event listener. sub->addEventListener([&ioMtx](const auto &events) { diff --git a/samples/cpp/DxFeedFileParser/src/main.cpp b/samples/cpp/DxFeedFileParser/src/main.cpp index 682bb7ab7..2525a46b1 100644 --- a/samples/cpp/DxFeedFileParser/src/main.cpp +++ b/samples/cpp/DxFeedFileParser/src/main.cpp @@ -47,7 +47,7 @@ int main(int argc, char *argv[]) { auto feed = endpoint->getFeed(); // Subscribe to a specified event and symbol. - auto sub = feed->createSubscription(types); + auto sub = feed->createSubscription(types.first); sub->addEventListener([&eventCounter, &ioMtx](const auto &events) { std::lock_guard lock{ioMtx}; diff --git a/samples/cpp/DxFeedIpfConnect/src/main.cpp b/samples/cpp/DxFeedIpfConnect/src/main.cpp index f54671d37..975118688 100644 --- a/samples/cpp/DxFeedIpfConnect/src/main.cpp +++ b/samples/cpp/DxFeedIpfConnect/src/main.cpp @@ -68,7 +68,7 @@ int main(int argc, char *argv[]) { auto types = CmdArgsUtils::parseTypes(argv[1]); auto ipfFile = argv[2]; - auto sub = DXFeed::getInstance()->createSubscription(types); + auto sub = DXFeed::getInstance()->createSubscription(types.first); sub->addEventListener([](auto &&events) { for (auto &&event : events) {