mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-09 10:00:27 +00:00
feat: support max running tasks config (#112)
This commit is contained in:
1 parent
1e08ecd8db
commit
d9c5ca339f
22 files changed
+269
-129
No files matched your search
@@ -73,15 +73,12 @@ Future<T> _parse<T>(
|
||||
) async {
|
||||
try {
|
||||
var resp = await fetch();
|
||||
if (fromJsonT != null) {
|
||||
final result = Result<T>.fromJson(resp.data, fromJsonT);
|
||||
if (result.code == 0) {
|
||||
return result.data as T;
|
||||
} else {
|
||||
throw Exception(result);
|
||||
}
|
||||
fromJsonT ??= (json) => null as T;
|
||||
final result = Result<T>.fromJson(resp.data, fromJsonT);
|
||||
if (result.code == 0) {
|
||||
return result.data as T;
|
||||
} else {
|
||||
return null as T;
|
||||
throw Exception(result);
|
||||
}
|
||||
} on DioError catch (e) {
|
||||
throw Exception(Result(code: 1000, msg: e.message));
|
||||
|
||||
Reference in new issue
Block a user