mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 03:44:02 +02:00
better error handling for asset browser
This commit is contained in:
parent
1678c9be20
commit
c65b5b63f0
3 changed files with 48 additions and 30 deletions
|
@ -56,12 +56,13 @@ Window {
|
|||
Assets.deleteMappings(path, function(err) {
|
||||
if (err) {
|
||||
console.log("Error deleting path: ", path, err);
|
||||
errorMessage("There was an error deleting:\n" + path + "\n\nPlease try again.");
|
||||
|
||||
box = errorMessageBox("There was an error deleting:\n" + path + "\n" + Assets.getErrorString(err));
|
||||
box.selected.connect(reload);
|
||||
} else {
|
||||
console.log("Finished deleting path: ", path);
|
||||
reload();
|
||||
}
|
||||
|
||||
reload();
|
||||
});
|
||||
|
||||
}
|
||||
|
@ -76,7 +77,8 @@ Window {
|
|||
Assets.renameMapping(oldPath, newPath, function(err) {
|
||||
if (err) {
|
||||
console.log("Error renaming: ", oldPath, "=>", newPath, " - error ", err);
|
||||
errorMessage("There was an error renaming:\n" + oldPath + " to " + newPath + "\n\nPlease try again.");
|
||||
box = errorMessageBox("There was an error renaming:\n" + oldPath + " to " + newPath + "\n" + Assets.getErrorString(err));
|
||||
box.selected.connect(reload);
|
||||
} else {
|
||||
console.log("Finished rename: ", oldPath, "=>", newPath);
|
||||
}
|
||||
|
@ -119,9 +121,11 @@ Window {
|
|||
Assets.mappingModel.refresh();
|
||||
}
|
||||
|
||||
function handleGetMappingsError() {
|
||||
errorMessage("There was a problem retreiving the list of assets from your Asset Server.\n"
|
||||
+ "Please make sure you are connected to the Asset Server and try again. ");
|
||||
function handleGetMappingsError(errorCode) {
|
||||
errorMessageBox(
|
||||
"There was a problem retreiving the list of assets from your Asset Server.\n"
|
||||
+ Assets.getErrorString(errorCode)
|
||||
);
|
||||
}
|
||||
|
||||
function addToWorld() {
|
||||
|
@ -234,12 +238,12 @@ Window {
|
|||
});
|
||||
}
|
||||
|
||||
function errorMessage(message) {
|
||||
desktop.messageBox({
|
||||
icon: OriginalDialogs.StandardIcon.Error,
|
||||
buttons: OriginalDialogs.StandardButton.Ok,
|
||||
text: "Error",
|
||||
informativeText: message
|
||||
function errorMessageBox(message) {
|
||||
return desktop.messageBox({
|
||||
icon: hifi.icons.warning,
|
||||
defaultButton: OriginalDialogs.StandardButton.Ok,
|
||||
title: "Error",
|
||||
text: message
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,27 @@ AssetMappingsScriptingInterface::AssetMappingsScriptingInterface() {
|
|||
_proxyModel.sort(0);
|
||||
}
|
||||
|
||||
QString AssetMappingsScriptingInterface::getErrorString(int errorCode) const {
|
||||
switch (errorCode) {
|
||||
case MappingRequest::NoError:
|
||||
return "No error";
|
||||
case MappingRequest::NotFound:
|
||||
return "Asset not found";
|
||||
case MappingRequest::NetworkError:
|
||||
return "Unable to communicate with Asset Server";
|
||||
case MappingRequest::PermissionDenied:
|
||||
return "Permission denied";
|
||||
case MappingRequest::InvalidPath:
|
||||
return "Path is invalid";
|
||||
case MappingRequest::InvalidHash:
|
||||
return "Hash is invalid";
|
||||
case MappingRequest::UnknownError:
|
||||
return "Asset Server internal error";
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
void AssetMappingsScriptingInterface::setMapping(QString path, QString hash, QJSValue callback) {
|
||||
auto assetClient = DependencyManager::get<AssetClient>();
|
||||
auto request = assetClient->createSetMappingRequest(path, hash);
|
||||
|
@ -113,22 +134,16 @@ void AssetMappingsScriptingInterface::renameMapping(QString oldPath, QString new
|
|||
}
|
||||
|
||||
|
||||
AssetMappingItem::AssetMappingItem(const QString& name, const QString& fullPath, bool isFolder)
|
||||
: name(name),
|
||||
AssetMappingItem::AssetMappingItem(const QString& name, const QString& fullPath, bool isFolder) :
|
||||
name(name),
|
||||
fullPath(fullPath),
|
||||
isFolder(isFolder) {
|
||||
isFolder(isFolder)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static int assetMappingModelMetatypeId = qRegisterMetaType<AssetMappingModel*>("AssetMappingModel*");
|
||||
|
||||
AssetMappingModel::AssetMappingModel() {
|
||||
}
|
||||
|
||||
AssetMappingModel::~AssetMappingModel() {
|
||||
qDebug() << " DEST";
|
||||
}
|
||||
|
||||
void AssetMappingModel::refresh() {
|
||||
qDebug() << "Refreshing asset mapping model";
|
||||
auto assetClient = DependencyManager::get<AssetClient>();
|
||||
|
@ -221,7 +236,9 @@ void AssetMappingModel::refresh() {
|
|||
//removeitem->index();
|
||||
}
|
||||
} else {
|
||||
emit errorGettingMappings(uint8_t(request->getError()));
|
||||
qDebug() << "THE ERROR IS" << request->getError();
|
||||
qDebug() << "Casted error is" << static_cast<int>(request->getError());
|
||||
emit errorGettingMappings(static_cast<int>(request->getError()));
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -33,17 +33,12 @@
|
|||
class AssetMappingModel : public QStandardItemModel {
|
||||
Q_OBJECT
|
||||
public:
|
||||
AssetMappingModel();
|
||||
~AssetMappingModel();
|
||||
|
||||
// QVariant AssetMappingModel::data(const QModelIndex& index, int role) const;
|
||||
|
||||
Q_INVOKABLE void refresh();
|
||||
|
||||
bool isKnownMapping(QString path) const { return _pathToItemMap.contains(path); };
|
||||
|
||||
signals:
|
||||
void errorGettingMappings(uint8_t error);
|
||||
void errorGettingMappings(int error);
|
||||
|
||||
private:
|
||||
QHash<QString, QStandardItem*> _pathToItemMap;
|
||||
|
@ -62,6 +57,8 @@ public:
|
|||
|
||||
Q_INVOKABLE bool isKnownMapping(QString path) const { return _assetMappingModel.isKnownMapping(path); };
|
||||
|
||||
Q_INVOKABLE QString getErrorString(int errorCode) const;
|
||||
|
||||
Q_INVOKABLE void setMapping(QString path, QString hash, QJSValue callback);
|
||||
Q_INVOKABLE void getMapping(QString path, QJSValue callback);
|
||||
Q_INVOKABLE void deleteMappings(QStringList paths, QJSValue callback);
|
||||
|
|
Loading…
Reference in a new issue