Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions app/lib/backend/http/http_pool_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ class HttpPoolManager {
lastError = e;
} on http.ClientException catch (e) {
lastError = e;
} on HandshakeException catch (e) {
lastError = e;
} on TlsException catch (e) {
lastError = e;
Comment on lines +76 to +79
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Since HandshakeException is a subtype of TlsException, you can simplify this by catching only TlsException. This will handle HandshakeException and any other potential TLS-related exceptions (like CertificateException) in a single block.

      } on TlsException catch (e) {
        // This catches HandshakeException and other TlsExceptions.
        lastError = e;
      }

} catch (e) {
lastError = e;
rethrow;
Expand All @@ -84,6 +88,12 @@ class HttpPoolManager {
}

if (lastResponse != null) return lastResponse;

// Return synthetic 503 for TLS/certificate errors instead of crashing
if (lastError is HandshakeException || lastError is TlsException) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

To align with the simplification of catching only TlsException, this condition can also be simplified.

    if (lastError is TlsException) {

return http.Response('', 503, reasonPhrase: 'TLS error: $lastError');
}

throw lastError ?? Exception('Request failed with unknown error');
}

Expand Down