Add Dio timeouts and map backend errors to user-friendly messages

Set 5s/15s/15s connect/receive/send timeouts so calls fail fast instead of
hanging. Introduce dioErrorToUserMessage() and route DioException-throwing
call sites (device actions, devices list, notifications list, scanners
status card) through it, replacing raw e.toString() output. Notifications
list now surfaces load errors inline in the theme's error color, matching
the devices list pattern. Status dots show the mapped detail as a tooltip.
Stop logging the API key in cleartext.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
rzuasti
2026-05-31 09:06:56 -04:00
co-authored by Claude Opus 4.7
parent 0f6296759d
commit 7954a9c755
5 changed files with 104 additions and 28 deletions
+12 -3
View File
@@ -42,7 +42,10 @@ Future<void> confirmForgetDevice(
onRefresh();
} catch (e) {
if (!context.mounted) return;
UISnackbars.showError(context, 'Failed to forget device: $e');
UISnackbars.showError(
context,
'Failed to forget device. ${dioErrorToUserMessage(e)}',
);
}
}
@@ -157,7 +160,10 @@ Future<void> showEditDeviceDialog(
onRefresh();
} catch (e) {
if (!context.mounted) return;
UISnackbars.showError(context, 'Failed to update device: $e');
UISnackbars.showError(
context,
'Failed to update device. ${dioErrorToUserMessage(e)}',
);
}
}
@@ -260,6 +266,9 @@ Future<void> showRegisterDeviceDialog(
onRefresh();
} catch (e) {
if (!context.mounted) return;
UISnackbars.showError(context, 'Failed to register device: $e');
UISnackbars.showError(
context,
'Failed to register device. ${dioErrorToUserMessage(e)}',
);
}
}
+7 -2
View File
@@ -102,7 +102,7 @@ class _DeviceListState extends State<DeviceList> with RouteAware {
} catch (e) {
if (!mounted) return;
setState(() {
_error = e.toString();
_error = dioErrorToUserMessage(e);
_isLoading = false;
});
}
@@ -235,7 +235,12 @@ class _DeviceListState extends State<DeviceList> with RouteAware {
return const Center(child: CircularProgressIndicator());
}
if (_error != null) {
return Center(child: Text('Error: $_error'));
return Center(
child: Text(
'Error: $_error',
style: TextStyle(color: Theme.of(context).colorScheme.error),
),
);
}
if (_devices.isEmpty) {
final theme = Theme.of(context);