removed the try catch again #15

Merged
Hugo Bayer merged 1 commit from Hugo/093519012020/RemovedTheTryCatchAgain into master 2020-01-29 08:37:12 +00:00

View file

@ -155,7 +155,8 @@ class _ServerListState extends State<ServerList> {
builder: (BuildContext context) {
return AlertDialog(
title: Text('Adding a server'),
content: SingleChildScrollView(child: Form(
content: SingleChildScrollView(
child: Form(
key: _formKey,
child: Column(
mainAxisSize: MainAxisSize.min,
@ -173,7 +174,8 @@ class _ServerListState extends State<ServerList> {
child: RaisedButton(
child: Text("Add"),
onPressed: () {
if (_formKey.currentState.validate()&&uri.text.isNotEmpty) {
if (_formKey.currentState.validate() &&
uri.text.isNotEmpty) {
_formKey.currentState.save();
Server server = Server(uri.text, uri.text);
servers.add(server);
@ -186,7 +188,8 @@ class _ServerListState extends State<ServerList> {
],
),
),
),);
),
);
},
);
}
@ -220,7 +223,10 @@ class _ServerListState extends State<ServerList> {
decoration: BoxDecoration(
border: Border(top: BorderSide(color: Colors.grey))),
),
Text(servers[index].uri,textAlign: TextAlign.left,),
Text(
servers[index].uri,
textAlign: TextAlign.left,
),
],
);
}
@ -375,17 +381,11 @@ class _ServerListState extends State<ServerList> {
var location = uri.path;
for (int i = 0; i < 5; i++) {
Response response;
try {
response = await HttpUtils.getForFullResponse(
Response response = await HttpUtils.getForFullResponse(
scheme + "://" + host,
headers: <String, String>{"Location": location})
.timeout(new Duration(seconds: 3));
} catch (error){
if (error == TimeoutException)
return ServerStatus.timeout;
throw error;
}
if (response.statusCode > 199 && response.statusCode < 300) {
return ServerStatus.ok;
} else if (response.statusCode == HttpStatus.movedPermanently ||