Skip to content

Commit

Permalink
Fix exception not shown
Browse files Browse the repository at this point in the history
  • Loading branch information
shoothzj committed Aug 2, 2021
1 parent 164c9e5 commit 25fd003
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
14 changes: 5 additions & 9 deletions lib/api/pulsar/pulsar_cluster_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ class PulsarClusterAPi {
}
String version = versionResponse.body;

String tenantInfo = "";
await PulsarTenantAPi.getTenantInfo(host, port, "public")
.then((value) => tenantInfo = value);
String tenantInfo =
await PulsarTenantAPi.getTenantInfo(host, port, "public");
String cluster =
((json.decode(tenantInfo) as Map)["allowedClusters"] as List)[0];
url = 'http://$host:${port.toString()}/admin/v2/brokers/$cluster';
Expand All @@ -40,11 +39,8 @@ class PulsarClusterAPi {
}
String leader = json.decode(leaderBrokerResponse.body)["serviceUrl"];

List<ClusterResp> respList = new List.empty(growable: true);
brokers.forEach((element) {
respList.add(new ClusterResp(
element, leader.contains(element).toString(), version));
});
return respList;
return brokers
.map((e) => ClusterResp(e, leader.contains(e).toString(), version))
.toList();
}
}
5 changes: 2 additions & 3 deletions lib/vm/pulsar/pulsar_cluster_view_model.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import 'package:paas_dashboard_flutter/api/pulsar/pulsar_cluster_api.dart';
import 'package:paas_dashboard_flutter/module/pulsar/pulsar_cluster.dart';
import 'package:paas_dashboard_flutter/persistent/po/pulsar_instance_po.dart';

import '../base_load_list_page_view_model.dart';
import 'package:paas_dashboard_flutter/vm/base_load_list_page_view_model.dart';

class PulsarClusterViewModel extends BaseLoadListPageViewModel<ClusterResp> {
List<ClusterResp> instances = <ClusterResp>[];
Expand Down Expand Up @@ -31,11 +30,11 @@ class PulsarClusterViewModel extends BaseLoadListPageViewModel<ClusterResp> {
try {
this.fullList = await PulsarClusterAPi.cluster(host, port);
this.displayList = this.fullList;
loadSuccess();
} on Exception catch (e) {
loadException = e;
loading = false;
}
loadSuccess();
notifyListeners();
}

Expand Down

0 comments on commit 25fd003

Please sign in to comment.