mirror of
https://github.com/rzuasti/oott.git
synced 2026-07-08 19:21:54 +02:00
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:
co-authored by
Claude Opus 4.7
parent
0f6296759d
commit
7954a9c755
@@ -48,7 +48,7 @@ class _ScannersStatusCardState extends State<ScannersStatusCard> {
|
||||
try {
|
||||
arp = await BackendAPI.instance.getArpScannerStatus();
|
||||
} catch (e) {
|
||||
arpError = e.toString();
|
||||
arpError = dioErrorToUserMessage(e);
|
||||
}
|
||||
|
||||
MdnsScannerStatus? mdns;
|
||||
@@ -56,7 +56,7 @@ class _ScannersStatusCardState extends State<ScannersStatusCard> {
|
||||
try {
|
||||
mdns = await BackendAPI.instance.getMdnsScannerStatus();
|
||||
} catch (e) {
|
||||
mdnsError = e.toString();
|
||||
mdnsError = dioErrorToUserMessage(e);
|
||||
}
|
||||
|
||||
if (!mounted) return;
|
||||
@@ -99,9 +99,9 @@ class _ScannersStatusCardState extends State<ScannersStatusCard> {
|
||||
children: [
|
||||
Text('Status', style: Theme.of(context).textTheme.titleMedium),
|
||||
const SizedBox(height: 12),
|
||||
_scannerRow(context, arpColor, 'ARP', arpText),
|
||||
_scannerRow(context, arpColor, 'ARP', arpText, _arpError),
|
||||
const SizedBox(height: 8),
|
||||
_scannerRow(context, mdnsColor, 'mDNS', mdnsText),
|
||||
_scannerRow(context, mdnsColor, 'mDNS', mdnsText, _mdnsError),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -114,10 +114,15 @@ class _ScannersStatusCardState extends State<ScannersStatusCard> {
|
||||
Color color,
|
||||
String name,
|
||||
String statusText,
|
||||
String? errorMessage,
|
||||
) {
|
||||
Widget dot = Icon(Icons.circle, color: color, size: 12);
|
||||
if (errorMessage != null) {
|
||||
dot = Tooltip(message: errorMessage, child: dot);
|
||||
}
|
||||
return Row(
|
||||
children: [
|
||||
Icon(Icons.circle, color: color, size: 12),
|
||||
dot,
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Text(name, style: Theme.of(context).textTheme.bodyMedium),
|
||||
|
||||
Reference in New Issue
Block a user