From abf91874c349e3cd278e06f5b66b447c71a83b76 Mon Sep 17 00:00:00 2001 From: bvandeusen Date: Sun, 1 Mar 2026 14:48:49 -0500 Subject: [PATCH] Show specific error reason on setup screen connection failure Instead of a generic "Could not reach server" for all failures, show the actual cause: SSL cert error, timeout, or the raw connection error message. This makes it possible to diagnose setup issues on-device without needing a debugger. Also extend connect timeout from 5s to 10s. Co-Authored-By: Claude Sonnet 4.6 --- lib/screens/setup/setup_screen.dart | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/screens/setup/setup_screen.dart b/lib/screens/setup/setup_screen.dart index 2d20490..1e66ff6 100644 --- a/lib/screens/setup/setup_screen.dart +++ b/lib/screens/setup/setup_screen.dart @@ -37,22 +37,32 @@ class _SetupScreenState extends ConsumerState { try { final dio = Dio(BaseOptions( - connectTimeout: const Duration(seconds: 5), + connectTimeout: const Duration(seconds: 10), // Accept any HTTP status — only network-level failures throw. // A 401 or 200 both mean the server is reachable. validateStatus: (_) => true, )); await dio.get('$url/api/auth/status'); - } on DioException catch (_) { + } on DioException catch (e) { + final msg = switch (e.type) { + DioExceptionType.badCertificate => + 'SSL certificate error. If using a self-signed cert, it must be trusted on this device.', + DioExceptionType.connectionTimeout || + DioExceptionType.receiveTimeout => + 'Connection timed out. The server may be down or unreachable.', + DioExceptionType.connectionError => + 'Cannot connect: ${e.message ?? "network error"}', + _ => 'Error: ${e.message ?? e.type.name}', + }; setState(() { _testing = false; - _error = 'Could not reach server. Check the URL and try again.'; + _error = msg; }); return; - } catch (_) { + } catch (e) { setState(() { _testing = false; - _error = 'Could not reach server. Check the URL and try again.'; + _error = 'Unexpected error: $e'; }); return; }