JoystreamClassic / extension-cpp

C++ libtorrent extension library
MIT License
0 stars 3 forks source link

No error catch for startDownloading #24

Closed rllola closed 7 years ago

rllola commented 7 years ago

When in startDownloading we never checked if it throw error https://github.com/JoyStream/extension-cpp/blob/master/sources/src/TorrentPlugin.cpp#L478

See doc in protocol_session :

        /**
         * @brief Start downloading from sellers.
         *
         * ...
         *
         * @param contractTx contract transaction
         * @param peerToStartDownloadInformationMap ...
         * @return void
         * @throws exception::StateIncompatibleOperation if @c\ state() != SessionState::started \@c
         * @throws exception::SessionModeNotSetException if @c\ mode() != SessionMode::buying \@c
         * @throws exception::NoLongerSendingInvitations if invitations are no longer being sent in buying mode (_state != BuyingState::sending_invitations)
         */
        void startDownloading(const Coin::Transaction & contractTx,
                              const PeerToStartDownloadInformationMap<ConnectionIdType> & peerToStartDownloadInformationMap,
                              const PickNextPieceMethod<ConnectionIdType> & pickNextPieceMethod);

We should try to catch them and add an error in the startDownload alert so the electron app can use this error.

rllola commented 7 years ago

This error is actually being catch by detail::subroutine_handler::CreateGenericHandler so the errors are never throw into any alerts but are thrown in the callbacks which means that if we recieve the alert is that no error has occured.