} else {
showDialog(
context: context,
- builder: (context) => AlertDialog(
- title: Text('Connection error'),
- content: Text('Could not establish connection: $e'),
- actions: [
- TextButton(
- onPressed: () => Navigator.of(context).pop(),
- child: Text('Close'),
- ),
- ],
- ),
+ builder: (context) => ConnectionErrorDialog(exception: e),
);
}
}
} else {
if (showConnectionError) {
showDialog(
- context: context,
- builder: (context) => AlertDialog(
- title: Text('Connection error'),
- content: Text('Could not establish connection.'),
- actions: [
- TextButton(
- onPressed: () => Navigator.of(context).pop(),
- child: Text('Close'),
- ),
- ],
- ),
- );
+ context: context,
+ builder: (context) => ConnectionErrorDialog(
+ exception: e,
+ ));
} else {
throw e;
}
}
}
+class ConnectionErrorDialog extends StatelessWidget {
+ final exception;
+
+ const ConnectionErrorDialog({
+ Key? key,
+ required this.exception,
+ }) : super(key: key);
+
+ @override
+ Widget build(BuildContext context) {
+ return AlertDialog(
+ title: Text('Connection error'),
+ content: Text('Could not establish connection: ${this.exception}'),
+ actions: [
+ TextButton(
+ onPressed: () => Navigator.of(context).pop(),
+ child: Text('Close'),
+ ),
+ ],
+ );
+ }
+}
+
class ProxmoxApiErrorDialog extends StatelessWidget {
final proxclient.ProxmoxApiException exception;
print(trace);
showDialog(
context: context,
- builder: (context) => AlertDialog(
- title: Text('Connection error'),
- content: Text('Could not establish connection.'),
- actions: [
- TextButton(
- onPressed: () => Navigator.of(context).pop(),
- child: Text('Close'),
- ),
- ],
+ builder: (context) => ConnectionErrorDialog(
+ exception: e,
),
);
}