提交 7fefa37f authored 作者: 史晓晨's avatar 史晓晨

feat:下载-异常信息处理

上级 b3fc507c
...@@ -75,9 +75,9 @@ class AppUpgradeControl { ...@@ -75,9 +75,9 @@ class AppUpgradeControl {
findOtherLogic<AppUpgradeDialogLogic>()?.updateDownload(false); findOtherLogic<AppUpgradeDialogLogic>()?.updateDownload(false);
ApkUpdatePlatform.instance.installApk(path); ApkUpdatePlatform.instance.installApk(path);
}, },
onError: (error) { onError: (Exception error) {
findOtherLogic<AppUpgradeDialogLogic>()?.updateDownload(false); findOtherLogic<AppUpgradeDialogLogic>()?.updateDownload(false);
ToastUtil.showToast("下载失败,请稍后重新"); ToastUtil.showToast(error.toString());
}, },
); );
} }
......
...@@ -6,7 +6,6 @@ import 'package:apk_update/utils/dio_update_util.dart'; ...@@ -6,7 +6,6 @@ import 'package:apk_update/utils/dio_update_util.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import '../../../../apk_update_platform_interface.dart'; import '../../../../apk_update_platform_interface.dart';
import '../../../../utils/toast_util.dart';
import '../../../../utils/utils.dart'; import '../../../../utils/utils.dart';
import '../../../common/constants.dart'; import '../../../common/constants.dart';
import 'package:path/path.dart' as p; import 'package:path/path.dart' as p;
...@@ -36,7 +35,7 @@ class OSSDownloadImpl implements DownloadService { ...@@ -36,7 +35,7 @@ class OSSDownloadImpl implements DownloadService {
try { try {
String? path = await createDir(); String? path = await createDir();
if (path == null) { if (path == null) {
ToastUtil.showToast("下载路径错误,请稍后重新"); onError?.call(Exception("下载路径错误,请稍后重新"));
return; return;
} }
File apkFile = File("$path/${getFileName(url)}"); File apkFile = File("$path/${getFileName(url)}");
...@@ -50,7 +49,7 @@ class OSSDownloadImpl implements DownloadService { ...@@ -50,7 +49,7 @@ class OSSDownloadImpl implements DownloadService {
await deleteFiles(Directory(path)); await deleteFiles(Directory(path));
var ossInfo = await getOssInfo(); var ossInfo = await getOssInfo();
if (ossInfo == null) { if (ossInfo == null) {
ToastUtil.showToast("oss下载失败"); onError?.call(Exception("oss信息获取失败,请稍后重新"));
return; return;
} }
// 使用OSS下载 // 使用OSS下载
...@@ -68,7 +67,7 @@ class OSSDownloadImpl implements DownloadService { ...@@ -68,7 +67,7 @@ class OSSDownloadImpl implements DownloadService {
if (isDownloadFailed) { if (isDownloadFailed) {
// 下载失败 // 下载失败
onError?.call(Exception('下载失败: oss')); onError?.call(Exception("oss下载失败"));
return; return;
} }
if (isDownloadSuccess) { if (isDownloadSuccess) {
...@@ -90,7 +89,7 @@ class OSSDownloadImpl implements DownloadService { ...@@ -90,7 +89,7 @@ class OSSDownloadImpl implements DownloadService {
localPathFileName); localPathFileName);
} catch (e) { } catch (e) {
debugPrint(e.toString()); debugPrint(e.toString());
ToastUtil.showToast(e.toString()); onError?.call(Exception(e.toString()));
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论