fix: remove unneeded exceptions

This commit is contained in:
Richard Ramos 2022-01-20 11:50:10 -04:00
parent 99ebb07d5c
commit 2a461488b2
45 changed files with 112 additions and 327 deletions

View File

@ -1,22 +1,11 @@
#pragma once
#include <stdexcept>
class AppControllerDelegate
{
public:
virtual void startupDidLoad()
{
throw std::domain_error("Not implemented");
}
virtual void startupDidLoad() = 0;
virtual void mainDidLoad()
{
throw std::domain_error("Not implemented");
}
virtual void mainDidLoad() = 0;
virtual void userLoggedIn()
{
throw std::domain_error("Not implemented");
}
virtual void userLoggedIn() = 0;
};

View File

@ -7,9 +7,9 @@ namespace Modules
{
namespace Main
{
Controller::Controller(ModuleControllerDelegateInterface* d, QObject* parent)
Controller::Controller(ModuleControllerDelegateInterface* delegate, QObject* parent)
: QObject(parent)
, m_delegate(d)
, m_delegate(delegate)
{ }
void Controller::init() { }

View File

@ -13,7 +13,7 @@ namespace Main
class Controller : public QObject, ControllerInterface
{
public:
Controller(ModuleControllerDelegateInterface* d, QObject* parent = nullptr);
Controller(ModuleControllerDelegateInterface* delegate, QObject* parent = nullptr);
void init() override;
private:

View File

@ -1,7 +1,5 @@
#pragma once
#include <stdexcept>
namespace Modules
{
namespace Main
@ -12,10 +10,7 @@ namespace Main
class ControllerInterface
{
public:
virtual void init()
{
throw std::domain_error("Not implemented");
}
virtual void init() = 0;
};
} // namespace Main
} // namespace Modules

View File

@ -1,10 +1,5 @@
#pragma once
#include "accounts/service_interface.h"
#include "app_controller_delegate.h"
#include "controller.h"
#include <stdexcept>
namespace Modules
{
namespace Main

View File

@ -1,7 +1,5 @@
#pragma once
#include <stdexcept>
namespace Modules
{
namespace Main
@ -9,10 +7,7 @@ namespace Main
class ModuleViewDelegateInterface
{
public:
virtual void viewDidLoad()
{
throw std::domain_error("Not implemented");
}
virtual void viewDidLoad() = 0;
};
}; // namespace Main
}; // namespace Modules

View File

@ -11,10 +11,9 @@ namespace Modules
{
namespace Main
{
Module::Module(AppControllerDelegate* d)
Module::Module(AppControllerDelegate* delegate)
: m_delegate(delegate)
{
m_delegate = d;
m_controller = new Controller(this);
m_view = new View(this);
}

View File

@ -22,7 +22,7 @@ private:
Controller* m_controller;
public:
Module(AppControllerDelegate* d);
Module(AppControllerDelegate* delegate);
~Module();
void load() override;
void checkIfModuleDidLoad();

View File

@ -1,7 +1,5 @@
#pragma once
#include <stdexcept>
namespace Modules
{
namespace Main
@ -9,10 +7,7 @@ namespace Main
class ModuleAccessInterface
{
public:
virtual void load()
{
throw std::domain_error("Not implemented");
}
virtual void load() = 0;
};
}; // namespace Main
}; // namespace Modules

View File

@ -7,11 +7,10 @@ namespace Modules
namespace Main
{
View::View(ModuleViewDelegateInterface* d, QObject* parent)
View::View(ModuleViewDelegateInterface* delegate, QObject* parent)
: QObject(parent)
{
m_delegate = d;
}
, m_delegate(delegate)
{ }
void View::load()
{

View File

@ -13,7 +13,7 @@ class View : public QObject
Q_OBJECT
public:
explicit View(ModuleViewDelegateInterface* d, QObject* parent = nullptr);
explicit View(ModuleViewDelegateInterface* delegate, QObject* parent = nullptr);
void load();
private:

View File

@ -8,12 +8,12 @@ namespace Modules
{
namespace Startup
{
Controller::Controller(ModuleControllerDelegateInterface* d,
Controller::Controller(ModuleControllerDelegateInterface* delegate,
Accounts::ServiceInterface* accountsService,
QObject* parent)
: QObject(parent)
, m_accountsService(accountsService)
, m_delegate(d)
, m_delegate(delegate)
{ }
void Controller::init()

View File

@ -14,7 +14,7 @@ namespace Startup
class Controller : public QObject, ControllerInterface
{
public:
Controller(ModuleControllerDelegateInterface* d,
Controller(ModuleControllerDelegateInterface* delegate,
Accounts::ServiceInterface* accountsService,
QObject* parent = nullptr);
void init() override;

View File

@ -10,14 +10,9 @@ namespace Startup
class ControllerInterface
{
public:
virtual void init()
{
throw std::domain_error("Not implemented");
}
virtual bool shouldStartWithOnboardingScreen()
{
throw std::domain_error("Not implemented");
}
virtual void init() = 0;
virtual bool shouldStartWithOnboardingScreen() = 0;
};
} // namespace Startup
} // namespace Modules

View File

@ -1,10 +1,5 @@
#pragma once
#include "accounts/service_interface.h"
#include "app_controller_delegate.h"
#include "controller.h"
#include <stdexcept>
namespace Modules
{
namespace Startup
@ -12,15 +7,9 @@ namespace Startup
class ModuleControllerDelegateInterface
{
public:
virtual void userLoggedIn()
{
throw std::domain_error("Not implemented");
}
virtual void userLoggedIn() = 0;
virtual void emitLogOut()
{
throw std::domain_error("Not implemented");
}
virtual void emitLogOut() = 0;
};
}; // namespace Startup
}; // namespace Modules

View File

@ -1,7 +1,5 @@
#pragma once
#include <stdexcept>
namespace Modules
{
namespace Startup
@ -9,10 +7,7 @@ namespace Startup
class ModuleLoginDelegateInterface
{
public:
virtual void loginDidLoad()
{
throw std::domain_error("Not implemented");
}
virtual void loginDidLoad() = 0;
};
}; // namespace Startup
}; // namespace Modules

View File

@ -1,7 +1,5 @@
#pragma once
#include <stdexcept>
namespace Modules
{
namespace Startup
@ -9,10 +7,7 @@ namespace Startup
class ModuleOnboardingDelegateInterface
{
public:
virtual void onboardingDidLoad()
{
throw std::domain_error("Not implemented");
}
virtual void onboardingDidLoad() = 0;
};
}; // namespace Startup
}; // namespace Modules

View File

@ -1,7 +1,5 @@
#pragma once
#include <stdexcept>
namespace Modules
{
namespace Startup
@ -9,10 +7,7 @@ namespace Startup
class ModuleViewDelegateInterface
{
public:
virtual void viewDidLoad()
{
throw std::domain_error("Not implemented");
}
virtual void viewDidLoad() = 0;
};
}; // namespace Startup
}; // namespace Modules

View File

@ -13,13 +13,13 @@ namespace Startup
{
namespace Login
{
Controller::Controller(ModuleControllerDelegateInterface* d,
Controller::Controller(ModuleControllerDelegateInterface* delegate,
// keychainService
Accounts::ServiceInterface* accountsService,
QObject* parent)
: QObject(parent)
, m_accountsService(accountsService)
, m_delegate(d)
, m_delegate(delegate)
{ }
void Controller::init()

View File

@ -19,7 +19,7 @@ class Controller : public QObject, ControllerInterface
Q_OBJECT
public:
Controller(ModuleControllerDelegateInterface* d,
Controller(ModuleControllerDelegateInterface* delegate,
// keychainService,
Accounts::ServiceInterface* accountsService,
QObject* parent = nullptr);

View File

@ -14,22 +14,13 @@ namespace Login
class ControllerInterface
{
public:
virtual void init()
{
throw std::domain_error("Not implemented");
}
virtual QVector<Accounts::AccountDto> getOpenedAccounts()
{
throw std::domain_error("Not implemented");
}
virtual void setSelectedAccountKeyUid(QString keyUid)
{
throw std::domain_error("Not implemented");
}
virtual void login(QString password)
{
throw std::domain_error("Not implemented");
}
virtual void init() = 0;
virtual QVector<Accounts::AccountDto> getOpenedAccounts() = 0;
virtual void setSelectedAccountKeyUid(QString keyUid) = 0;
virtual void login(QString password) = 0;
};
} // namespace Login
} // namespace Startup

View File

@ -1,10 +1,5 @@
#pragma once
#include "accounts/service_interface.h"
#include "app_controller_delegate.h"
#include "controller.h"
#include <stdexcept>
namespace Modules
{
namespace Startup
@ -14,20 +9,11 @@ namespace Login
class ModuleControllerDelegateInterface
{
public:
virtual void emitAccountLoginError(QString error)
{
throw std::domain_error("Not implemented");
}
virtual void emitAccountLoginError(QString error) = 0;
virtual void emitObtainingPasswordError(QString errorDescription)
{
throw std::domain_error("Not implemented");
}
virtual void emitObtainingPasswordError(QString errorDescription) = 0;
virtual void emitObtainingPasswordSuccess(QString password)
{
throw std::domain_error("Not implemented");
}
virtual void emitObtainingPasswordSuccess(QString password) = 0;
};
}; // namespace Login
}; // namespace Startup

View File

@ -1,7 +1,6 @@
#pragma once
#include "../item.h"
#include <QString>
#include <stdexcept>
namespace Modules
{
@ -12,20 +11,11 @@ namespace Login
class ModuleViewDelegateInterface
{
public:
virtual void viewDidLoad()
{
throw std::domain_error("Not implemented");
}
virtual void viewDidLoad() = 0;
virtual void setSelectedAccount(Item item)
{
throw std::domain_error("Not implemented");
}
virtual void setSelectedAccount(Item item) = 0;
virtual void login(QString password)
{
throw std::domain_error("Not implemented");
}
virtual void login(QString password) = 0;
};
}; // namespace Login
}; // namespace Startup

View File

@ -17,11 +17,11 @@ namespace Startup
{
namespace Login
{
Module::Module(Modules::Startup::ModuleLoginDelegateInterface* d,
Module::Module(Modules::Startup::ModuleLoginDelegateInterface* delegate,
// keychainService
Accounts::ServiceInterface* accountsService)
: m_delegate(delegate)
{
m_delegate = d;
m_controller = new Controller(this, accountsService);
m_view = new View(this);
m_moduleLoaded = false;
@ -33,7 +33,7 @@ Module::~Module()
delete m_view;
}
void Module::extractImages(Accounts::AccountDto account, QString &thumbnailImage, QString &largeImage)
void Module::extractImages(Accounts::AccountDto account, QString& thumbnailImage, QString& largeImage)
{
foreach(const Accounts::Image& img, account.images)
{

View File

@ -26,7 +26,7 @@ private:
bool m_moduleLoaded;
public:
Module(Modules::Startup::ModuleLoginDelegateInterface* d,
Module(Modules::Startup::ModuleLoginDelegateInterface* delegate,
// keychainService
Accounts::ServiceInterface* accountsService);
~Module();

View File

@ -1,7 +1,5 @@
#pragma once
#include <stdexcept>
namespace Modules
{
namespace Startup
@ -11,15 +9,9 @@ namespace Login
class ModuleAccessInterface
{
public:
virtual void load()
{
throw std::domain_error("Not implemented");
}
virtual void load() = 0;
virtual bool isLoaded()
{
throw std::domain_error("Not implemented");
}
virtual bool isLoaded() = 0;
};
}; // namespace Login
}; // namespace Startup

View File

@ -11,10 +11,10 @@ namespace Startup
{
namespace Login
{
View::View(ModuleViewDelegateInterface* d, QObject* parent)
View::View(ModuleViewDelegateInterface* delegate, QObject* parent)
: QObject(parent)
, m_delegate(delegate)
{
m_delegate = d;
m_model = new Model();
m_selectedAccount = new SelectedAccount();
}

View File

@ -21,7 +21,7 @@ class View : public QObject
Q_PROPERTY(Model* accountsModel READ getModel NOTIFY modelChanged)
public:
explicit View(ModuleViewDelegateInterface* d, QObject* parent = nullptr);
explicit View(ModuleViewDelegateInterface* delegate, QObject* parent = nullptr);
~View();
void load();

View File

@ -14,12 +14,11 @@ namespace Modules
{
namespace Startup
{
Module::Module(AppControllerDelegate* d,
Module::Module(AppControllerDelegate* delegate,
/*keychainService,*/
Accounts::ServiceInterface* accountsService)
: m_delegate(delegate)
{
m_delegate = d;
m_controller = new Controller(this, accountsService);
m_view = new View(this);

View File

@ -32,7 +32,7 @@ private:
Modules::Startup::Login::ModuleAccessInterface* m_loginModule;
public:
Module(AppControllerDelegate* d,
Module(AppControllerDelegate* delegate,
/*keychainService,*/ Accounts::ServiceInterface* accountsService);
~Module();
void load() override;

View File

@ -1,7 +1,5 @@
#pragma once
#include <stdexcept>
namespace Modules
{
namespace Startup
@ -9,15 +7,9 @@ namespace Startup
class ModuleAccessInterface
{
public:
virtual void load()
{
throw std::domain_error("Not implemented");
}
virtual void load() = 0;
virtual void moveToAppState()
{
throw std::domain_error("Not implemented");
}
virtual void moveToAppState() = 0;
};
}; // namespace Startup
}; // namespace Modules

View File

@ -13,12 +13,12 @@ namespace Startup
{
namespace Onboarding
{
Controller::Controller(ModuleControllerDelegateInterface* d,
Controller::Controller(ModuleControllerDelegateInterface* delegate,
Accounts::ServiceInterface* accountsService,
QObject* parent)
: QObject(parent)
, m_accountsService(accountsService)
, m_delegate(d)
, m_delegate(delegate)
{ }
void Controller::init()

View File

@ -19,7 +19,7 @@ class Controller : public QObject, ControllerInterface
Q_OBJECT
public:
Controller(ModuleControllerDelegateInterface* d,
Controller(ModuleControllerDelegateInterface* delegate,
Accounts::ServiceInterface* accountsService,
QObject* parent = nullptr);
void init() override;

View File

@ -14,34 +14,19 @@ namespace Onboarding
class ControllerInterface
{
public:
virtual void init()
{
throw std::domain_error("Not implemented");
}
virtual QVector<Accounts::GeneratedAccountDto> getGeneratedAccounts()
{
throw std::domain_error("Not implemented");
}
virtual void setSelectedAccountByIndex(int index)
{
throw std::domain_error("Not implemented");
}
virtual void storeSelectedAccountAndLogin(QString password)
{
throw std::domain_error("Not implemented");
}
virtual Accounts::GeneratedAccountDto getImportedAccount()
{
throw std::domain_error("Not implemented");
}
virtual QString validateMnemonic(QString mnemonic)
{
throw std::domain_error("Not implemented");
}
virtual void importMnemonic(QString mnemonic)
{
throw std::domain_error("Not implemented");
}
virtual void init() = 0;
virtual QVector<Accounts::GeneratedAccountDto> getGeneratedAccounts() = 0;
virtual void setSelectedAccountByIndex(int index) = 0;
virtual void storeSelectedAccountAndLogin(QString password) = 0;
virtual Accounts::GeneratedAccountDto getImportedAccount() = 0;
virtual QString validateMnemonic(QString mnemonic) = 0;
virtual void importMnemonic(QString mnemonic) = 0;
};
} // namespace Onboarding
} // namespace Startup

View File

@ -1,10 +1,5 @@
#pragma once
#include "accounts/service_interface.h"
#include "app_controller_delegate.h"
#include "controller.h"
#include <stdexcept>
namespace Modules
{
namespace Startup
@ -14,20 +9,11 @@ namespace Onboarding
class ModuleControllerDelegateInterface
{
public:
virtual void setupAccountError()
{
throw std::domain_error("Not implemented");
}
virtual void setupAccountError() = 0;
virtual void importAccountError()
{
throw std::domain_error("Not implemented");
}
virtual void importAccountError() = 0;
virtual void importAccountSuccess()
{
throw std::domain_error("Not implemented");
}
virtual void importAccountSuccess() = 0;
};
}; // namespace Onboarding
}; // namespace Startup

View File

@ -1,7 +1,6 @@
#pragma once
#include "accounts/generated_account.h"
#include <QString>
#include <stdexcept>
namespace Modules
{
@ -12,35 +11,17 @@ namespace Onboarding
class ModuleViewDelegateInterface
{
public:
virtual void viewDidLoad()
{
throw std::domain_error("Not implemented");
}
virtual void viewDidLoad() = 0;
virtual void setSelectedAccountByIndex(int index)
{
throw std::domain_error("Not implemented");
}
virtual void setSelectedAccountByIndex(int index) = 0;
virtual void storeSelectedAccountAndLogin(QString password)
{
throw std::domain_error("Not implemented");
}
virtual void storeSelectedAccountAndLogin(QString password) = 0;
virtual Accounts::GeneratedAccountDto getImportedAccount()
{
throw std::domain_error("Not implemented");
}
virtual Accounts::GeneratedAccountDto getImportedAccount() = 0;
virtual QString validateMnemonic(QString mnemonic)
{
throw std::domain_error("Not implemented");
}
virtual QString validateMnemonic(QString mnemonic) = 0;
virtual void importMnemonic(QString mnemonic)
{
throw std::domain_error("Not implemented");
}
virtual void importMnemonic(QString mnemonic) = 0;
};
}; // namespace Onboarding
}; // namespace Startup

View File

@ -1,14 +1,14 @@
#include "module.h"
#include "../interfaces/module_onboarding_delegate_interface.h"
#include "accounts/generated_account.h"
#include "accounts/service_interface.h"
#include "../interfaces/module_onboarding_delegate_interface.h"
#include "controller.h"
#include "singleton.h"
#include "view.h"
#include <QDebug>
#include <QObject>
#include <QQmlContext>
#include <QVariant>
#include <QDebug>
#include <iostream>
namespace Modules
@ -17,9 +17,10 @@ namespace Startup
{
namespace Onboarding
{
Module::Module(Modules::Startup::ModuleOnboardingDelegateInterface* d, Accounts::ServiceInterface* accountsService)
Module::Module(Modules::Startup::ModuleOnboardingDelegateInterface* delegate,
Accounts::ServiceInterface* accountsService)
: m_delegate(delegate)
{
m_delegate = d;
m_controller = new Controller(this, accountsService);
m_view = new View(this);
m_moduleLoaded = false;

View File

@ -25,7 +25,7 @@ private:
bool m_moduleLoaded;
public:
Module(Modules::Startup::ModuleOnboardingDelegateInterface* d, Accounts::ServiceInterface* accountsService);
Module(Modules::Startup::ModuleOnboardingDelegateInterface* delegate, Accounts::ServiceInterface* accountsService);
~Module();
void load() override;
bool isLoaded() override;

View File

@ -1,7 +1,5 @@
#pragma once
#include <stdexcept>
namespace Modules
{
namespace Startup
@ -11,15 +9,9 @@ namespace Onboarding
class ModuleAccessInterface
{
public:
virtual void load()
{
throw std::domain_error("Not implemented");
}
virtual void load() = 0;
virtual bool isLoaded()
{
throw std::domain_error("Not implemented");
}
virtual bool isLoaded() = 0;
};
}; // namespace Onboarding
}; // namespace Startup

View File

@ -1,7 +1,7 @@
#include "view.h"
#include "interfaces/module_view_delegate_interface.h"
#include <QObject>
#include <QDebug>
#include <QObject>
namespace Modules
{
@ -9,10 +9,10 @@ namespace Startup
{
namespace Onboarding
{
View::View(ModuleViewDelegateInterface* d, QObject* parent)
View::View(ModuleViewDelegateInterface* delegate, QObject* parent)
: QObject(parent)
, m_delegate(delegate)
{
m_delegate = d;
m_model = new Model();
}

View File

@ -22,7 +22,7 @@ class View : public QObject
Q_PROPERTY(QString importedAccountAddress READ getImportedAccountAddress NOTIFY importedAccountChanged)
public:
explicit View(ModuleViewDelegateInterface* d, QObject* parent = nullptr);
explicit View(ModuleViewDelegateInterface* delegate, QObject* parent = nullptr);
~View();
void load();

View File

@ -7,12 +7,11 @@ namespace Modules
namespace Startup
{
View::View(ModuleViewDelegateInterface* d, QObject* parent)
View::View(ModuleViewDelegateInterface* delegate, QObject* parent)
: QObject(parent)
, m_appState(AppState::OnboardingState)
{
m_delegate = d;
}
, m_delegate(delegate)
{ }
void View::load()
{

View File

@ -21,7 +21,7 @@ class View : public QObject
Q_PROPERTY(int appState READ getAppState NOTIFY appStateChanged)
public:
explicit View(ModuleViewDelegateInterface* d, QObject* parent = nullptr);
explicit View(ModuleViewDelegateInterface* delegate, QObject* parent = nullptr);
void emitLogOut();
void setAppState(AppState state);
void load();

View File

@ -6,7 +6,6 @@
#include <QJsonValue>
#include <QString>
#include <QVector>
#include <stdexcept>
namespace Accounts
{
@ -14,70 +13,31 @@ namespace Accounts
class ServiceInterface : public AppService
{
public:
virtual QVector<AccountDto> openedAccounts()
{
throw std::domain_error("Not implemented");
}
virtual QVector<AccountDto> openedAccounts() = 0;
virtual QVector<GeneratedAccountDto> generatedAccounts()
{
throw std::domain_error("Not implemented");
}
virtual QVector<GeneratedAccountDto> generatedAccounts() = 0;
virtual bool setupAccount(QString accountId, QString password)
{
throw std::domain_error("Not implemented");
}
virtual bool setupAccount(QString accountId, QString password) = 0;
virtual AccountDto getLoggedInAccount()
{
throw std::domain_error("Not implemented");
}
virtual AccountDto getLoggedInAccount() = 0;
virtual GeneratedAccountDto getImportedAccount()
{
throw std::domain_error("Not implemented");
}
virtual GeneratedAccountDto getImportedAccount() = 0;
virtual bool isFirstTimeAccountLogin()
{
throw std::domain_error("Not implemented");
}
virtual bool isFirstTimeAccountLogin() = 0;
virtual QString validateMnemonic(QString mnemonic)
{
throw std::domain_error("Not implemented");
}
virtual QString validateMnemonic(QString mnemonic) = 0;
virtual bool importMnemonic(QString mnemonic)
{
throw std::domain_error("Not implemented");
}
virtual bool importMnemonic(QString mnemonic) = 0;
virtual QString login(AccountDto account, QString password)
{
throw std::domain_error("Not implemented");
}
virtual QString login(AccountDto account, QString password) = 0;
virtual void clear()
{
throw std::domain_error("Not implemented");
}
virtual void clear() = 0;
virtual QString generateAlias(QString publicKey)
{
throw std::domain_error("Not implemented");
}
virtual QString generateAlias(QString publicKey) = 0;
virtual QString generateIdenticon(QString publicKey)
{
throw std::domain_error("Not implemented");
}
virtual QString generateIdenticon(QString publicKey) = 0;
virtual bool verifyAccountPassword(QString account, QString password)
{
throw std::domain_error("Not implemented");
}
virtual bool verifyAccountPassword(QString account, QString password) = 0;
};
} // namespace Accounts

View File

@ -1,12 +1,7 @@
#pragma once
#include <stdexcept>
class AppService
{
public:
virtual void init()
{
throw std::domain_error("Not implemented");
}
virtual void init() = 0;
};