Переглянути джерело

:art: Improve error message for installing marketplace package failed Fix https://github.com/siyuan-note/siyuan/issues/8507

Daniel 2 роки тому
батько
коміт
318b430c3b

+ 1 - 1
app/appearance/langs/en_US.json

@@ -1006,7 +1006,7 @@
     "43": "The maximum storage capacity of cloud space [%s] has been exceeded, and data upload cannot continue",
     "44": "Parse template failed: %s",
     "45": "Opening, please wait...",
-    "46": "The download of the [%s] failed due to network problems, please try again later",
+    "46": "Failed to install marketplace package [%s]: %s",
     "47": "Uninstall failed: %s",
     "48": "Only list the first [%d] sub-documents, if you need to adjust, please modify [Settings - Doc tree - Maximum number to list]",
     "49": "Please specify the daily note save path in the Notebook Settings",

+ 1 - 1
app/appearance/langs/es_ES.json

@@ -1006,7 +1006,7 @@
     "43": "Se ha superado la capacidad máxima de almacenamiento del espacio en la nube [%s] y la carga de datos no puede continuar",
     "44": "El proceso de análisis de la plantilla ha fallado: %s",
     "45": "Abriendo, por favor espere...",
-    "46": "La descarga del [%s] falló debido a problemas de red, por favor inténtelo más tarde",
+    "46": "Error al instalar el paquete del mercado [%s]: %s",
     "47": "Fallo en la desinstalación: %s",
     "48": "Sólo se listan los primeros [%d] subdocumentos, si necesita ajustarlos, modifique [Configuración - Árbol de documentos - Número máximo a listar]",
     "49": "Por favor, especifique la ruta de guardado de las notas diarias en la Configuración de la Libreta",

+ 1 - 1
app/appearance/langs/fr_FR.json

@@ -1006,7 +1006,7 @@
     "43": "La capacité de stockage maximale de l'espace cloud [%s] a été dépassée et le téléchargement des données ne peut pas continuer",
     "44": "L'analyse du template a échoué : %s",
     "45": "En cours d'ouverture, veuillez patienter...",
-    "46": "Le téléchargement du [%s] a échoué en raison de problèmes de réseau, veuillez réessayer plus tard.",
+    "46": "Échec de l'installation du package du marché [%s]: %s",
     "47": "La désinstallation a échoué : %s",
     "48": "Seuls les premiers [%d] sous-documents sont listés, si vous avez besoin d'ajuster, veuillez modifier [Paramètres - Arbre des documents - Nombre maximum de documents à lister].",
     "49": "Veuillez spécifier le chemin d'enregistrement des notes quotidiennes dans les paramètres du carnet de notes.",

+ 1 - 1
app/appearance/langs/zh_CHT.json

@@ -1006,7 +1006,7 @@
     "43": "已超過雲端空間最大存儲容量 [%s],無法繼續上傳數據",
     "44": "範本解析失敗:%s",
     "45": "正在打開,請稍等...",
-    "46": "因為網路問題導致下載 [%s] 失敗,請稍後重試",
+    "46": "安裝集市包 [%s] 失敗:%s",
     "47": "解除安裝失敗:%s",
     "48": "僅列出前 [%d] 個子文檔,如需調整請修改 [設置 - 文檔樹 - 最大列出數量]",
     "49": "請在筆記本設置中指定日記存放路徑",

+ 1 - 1
app/appearance/langs/zh_CN.json

@@ -1008,7 +1008,7 @@
     "43": "已超过云端空间最大存储容量 [%s],无法继续上传数据",
     "44": "模板解析失败:%s",
     "45": "正在打开,请稍等...",
-    "46": "因为网络问题导致下载 [%s] 失败,请稍后重试",
+    "46": "安装集市包 [%s] 失败:%s",
     "47": "卸载失败:%s",
     "48": "仅列出前 [%d] 个子文档,如需调整请修改 [设置 - 文档树 - 最大列出数量]",
     "49": "请在笔记本设置中指定日记存放路径",

+ 2 - 3
kernel/bazaar/package.go

@@ -535,11 +535,11 @@ func downloadPackage(repoURLHash string, pushProgress bool, systemID string) (da
 	}).Get(u)
 	if nil != err {
 		logging.LogErrorf("get bazaar package [%s] failed: %s", u, err)
-		return nil, errors.New("get bazaar package failed")
+		return nil, errors.New("get bazaar package failed: " + err.Error())
 	}
 	if 200 != resp.StatusCode {
 		logging.LogErrorf("get bazaar package [%s] failed: %d", u, resp.StatusCode)
-		return nil, errors.New("get bazaar package failed")
+		return nil, errors.New("get bazaar package failed: " + resp.Status)
 	}
 	data = buf.Bytes()
 
@@ -575,7 +575,6 @@ func installPackage(data []byte, installPath string) (err error) {
 	unzipPath := filepath.Join(tmpPackage, name)
 	if err = gulu.Zip.Unzip(tmp, unzipPath); nil != err {
 		logging.LogErrorf("write file [%s] failed: %s", installPath, err)
-		err = errors.New("write file failed")
 		return
 	}
 

+ 5 - 5
kernel/model/bazzar.go

@@ -66,7 +66,7 @@ func InstallBazaarPlugin(repoURL, repoHash, pluginName string) error {
 	installPath := filepath.Join(util.DataDir, "plugins", pluginName)
 	err := bazaar.InstallPlugin(repoURL, repoHash, installPath, Conf.System.ID)
 	if nil != err {
-		return errors.New(fmt.Sprintf(Conf.Language(46), pluginName))
+		return errors.New(fmt.Sprintf(Conf.Language(46), pluginName, err))
 	}
 	return nil
 }
@@ -119,7 +119,7 @@ func InstallBazaarWidget(repoURL, repoHash, widgetName string) error {
 	installPath := filepath.Join(util.DataDir, "widgets", widgetName)
 	err := bazaar.InstallWidget(repoURL, repoHash, installPath, Conf.System.ID)
 	if nil != err {
-		return errors.New(fmt.Sprintf(Conf.Language(46), widgetName))
+		return errors.New(fmt.Sprintf(Conf.Language(46), widgetName, err))
 	}
 	return nil
 }
@@ -163,7 +163,7 @@ func InstallBazaarIcon(repoURL, repoHash, iconName string) error {
 	installPath := filepath.Join(util.IconsPath, iconName)
 	err := bazaar.InstallIcon(repoURL, repoHash, installPath, Conf.System.ID)
 	if nil != err {
-		return errors.New(fmt.Sprintf(Conf.Language(46), iconName))
+		return errors.New(fmt.Sprintf(Conf.Language(46), iconName, err))
 	}
 	Conf.Appearance.Icon = iconName
 	Conf.Save()
@@ -214,7 +214,7 @@ func InstallBazaarTheme(repoURL, repoHash, themeName string, mode int, update bo
 	installPath := filepath.Join(util.ThemesPath, themeName)
 	err := bazaar.InstallTheme(repoURL, repoHash, installPath, Conf.System.ID)
 	if nil != err {
-		return errors.New(fmt.Sprintf(Conf.Language(46), themeName))
+		return errors.New(fmt.Sprintf(Conf.Language(46), themeName, err))
 	}
 
 	if !update {
@@ -270,7 +270,7 @@ func InstallBazaarTemplate(repoURL, repoHash, templateName string) error {
 	installPath := filepath.Join(util.DataDir, "templates", templateName)
 	err := bazaar.InstallTemplate(repoURL, repoHash, installPath, Conf.System.ID)
 	if nil != err {
-		return errors.New(fmt.Sprintf(Conf.Language(46), templateName))
+		return errors.New(fmt.Sprintf(Conf.Language(46), templateName, err))
 	}
 	return nil
 }