2222
2323#include " inputoutputmode.hpp"
2424
25+ #include " pcsc-cpp/pcsc-cpp.hpp"
26+ #include " electronic-id/electronic-id.hpp"
27+
2528#include < QJsonDocument>
2629#include < QJsonObject>
2730
@@ -48,6 +51,7 @@ void setIoStreamsToBinaryMode()
4851#endif
4952
5053using namespace pcsc_cpp ;
54+ using namespace electronic_id ;
5155
5256uint32_t readMessageLength (std::istream& input)
5357{
@@ -71,15 +75,13 @@ CommandWithArgumentsPtr readCommandFromStdin()
7175 const auto messageLength = readMessageLength (std::cin);
7276
7377 if (messageLength < 5 ) {
74- // FIXME: Pass errors back up to caller in stdin mode.
75- throw std::invalid_argument (" readCommandFromStdin: Message length is "
76- + std::to_string (messageLength) + " , at least 5 required" );
78+ throw ArgumentError (" readCommandFromStdin: Message length is "
79+ + std::to_string (messageLength) + " , at least 5 required" );
7780 }
7881
7982 if (messageLength > 8192 ) {
80- throw std::invalid_argument (" readCommandFromStdin: Message length "
81- + std::to_string (messageLength)
82- + " exceeds maximum allowed length 8192" );
83+ throw ArgumentError (" readCommandFromStdin: Message length " + std::to_string (messageLength)
84+ + " exceeds maximum allowed length 8192" );
8385 }
8486
8587 auto message = QByteArray (int (messageLength), ' \0 ' );
@@ -88,18 +90,16 @@ CommandWithArgumentsPtr readCommandFromStdin()
8890 const auto json = QJsonDocument::fromJson (message);
8991
9092 if (!json.isObject ()) {
91- // FIXME: Pass errors back up to caller in stdin mode.
92- throw std::invalid_argument (" readCommandFromStdin: Invalid JSON, not an object" );
93+ throw ArgumentError (" readCommandFromStdin: Invalid JSON, not an object" );
9394 }
9495
9596 const auto jsonObject = json.object ();
9697 const auto command = jsonObject[" command" ];
9798 const auto arguments = jsonObject[" arguments" ];
9899
99100 if (!command.isString () || !arguments.isObject ()) {
100- // FIXME: Pass errors back up to caller in stdin mode.
101- throw std::invalid_argument (" readCommandFromStdin: Invalid JSON, the main object does not "
102- " contain a 'command' string and 'arguments' object" );
101+ throw ArgumentError (" readCommandFromStdin: Invalid JSON, the main object does not "
102+ " contain a 'command' string and 'arguments' object" );
103103 }
104104
105105 return std::make_unique<CommandWithArguments>(commandNameToCommandType (command.toString ()),
0 commit comments