Show SSH exceptions as useful error messages in SnackBars
This commit is contained in:
parent
7251fce43a
commit
02d3341b3d
@ -103,8 +103,6 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
Future<void> doSSH(String user) async {
|
Future<void> doSSH(String user) async {
|
||||||
SSHSocket? socket;
|
SSHSocket? socket;
|
||||||
|
|
||||||
print("Connecting to SSH server...");
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
socket = await SSHSocket.connect(
|
socket = await SSHSocket.connect(
|
||||||
'192.168.0.15',
|
'192.168.0.15',
|
||||||
@ -123,11 +121,25 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
_output = utf8.decode(uptime);
|
_output = utf8.decode(uptime);
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} on SSHAuthError catch (_) {
|
||||||
print("Error: $e");
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
setState(() {
|
SnackBar(
|
||||||
_output = "Error: $e";
|
content: Text(
|
||||||
});
|
"Error! Server rejected our key. Maybe you need to register it first? Or you do not have access to this lock.",
|
||||||
|
),
|
||||||
|
duration: const Duration(seconds: 3),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
} on SocketException catch (_) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text(
|
||||||
|
"Error! Could not connect to SSH server. Maybe you are not in the right wifi network?",
|
||||||
|
),
|
||||||
|
duration: const Duration(seconds: 3),
|
||||||
|
),
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user