title: Unhandled Exception: SocketException flutter
body: <p>The goal is to get website from email. I want to catch Socket Exceptions in a try Catch statement, but the following error wasn't caught and no print statement.</p>
  <p>[VERBOSE-2:ui_dart_state.cc(177)] Unhandled Exception: SocketException: Failed host lookup: 'subdomain.domain.com' (OS Error: nodename nor servname provided, or not known, errno = 8).</p>
  <p>Following the flutter documentation <a href="https://dart.dev/guides/language/effective-dart/usage#prefer-asyncawait-over-using-raw-futures" rel="nofollow noreferrer">here</a> and <a href="https://dart.dev/guides/language/effective-dart/usage#avoid-catches-without-on-clauses" rel="nofollow noreferrer">here</a></p>
  <p>here is my code.</p>
  <pre><code>import 'package:http/http.dart' as http;
  
  Future&lt;void&gt; getWebsite(email) async {
      try {
        // get domain from email
        String _dom = new RegExp(r&quot;(?&lt;=[@]).+&quot;).stringMatch(email);
        // Get response status code from url
        final response = await http.get(&quot;https://$_dom&quot;);
        // Set Domain
        response.statusCode == 200 ? setDomain(&quot;https://$_dom&quot;) : setDomain(null);
      } on SocketException catch (_) {
        print(&quot;socket error&quot;);
      } on HttpException catch (_) {
        print(&quot;http error&quot;);
      } on FormatException catch (_) {
        print(&quot;format exception&quot;);
      } catch (e) {
        print(&quot;any exception&quot;);
      }
  }
  </code></pre>
  <p>Here is the result of flutter doctor -v</p>
  <p>[✓] Flutter (Channel master, 1.22.0-10.0.pre.153, on Mac OS X 10.15.5 19F101, locale en-US)
  • Flutter version 1.22.0-10.0.pre.153 at /Users/sean/developer/flutter
  • Framework revision 2e643651a9 (4 months ago), 2020-09-11 23:07:03 -0400
  • Engine revision 16b900b63e
  • Dart version 2.10.0 (build 2.10.0-117.0.dev)</p>
  <p>[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.0-rc1)
  • Android SDK at /Users/sean/Library/Android/sdk
  • Platform android-29, build-tools 30.0.0-rc1
  • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
  • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
  • All Android licenses accepted.</p>
  <p>[✓] Xcode - develop for iOS and macOS (Xcode 11.3)
  • Xcode at /Applications/Xcode.app/Contents/Developer
  • Xcode 11.3, Build version 11C29
  • CocoaPods version 1.9.1</p>
  <p>[✓] Android Studio (version 3.6)
  • Android Studio at /Applications/Android Studio.app/Contents
  • Flutter plugin version 45.1.1
  • Dart plugin version 192.7761
  • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)</p>
  <p>[✓] VS Code (version 1.52.1)
  • VS Code at /Applications/Visual Studio Code.app/Contents
  • Flutter extension version 3.18.0</p>
  <p>[✓] Connected device (1 available)<br />
  • iPhone 11 Pro (mobile) • E280A6FB-4AF7-4409-B79E-FA4E652C4FE0 • ios • com.apple.CoreSimulator.SimRuntime.iOS-13-3 (simulator)</p>
  <p>• No issues found!</p>
  <p>Here is what I see in the console</p>
  <pre><code>Launching lib/main.dart on iPhone 11 Pro in debug mode...
  Running pod install...
  Running Xcode build...
  Xcode build done.                                           552.8s
  Waiting for iPhone 11 Pro to report its views...
  Debug service listening on ws://127.0.0.1:58043/ZgdnQH-v_BY=/ws
  Syncing files to device iPhone 11 Pro...
  [VERBOSE-2:ui_dart_state.cc(177)] Unhandled Exception: SocketException: Failed host lookup: 'av.abbott.com' (OS Error: nodename nor servname provided, or not known, errno = 8)
  #0      _NativeSocket.lookup.&lt;anonymous closure&gt; (dart:io-patch/socket_patch.dart:502:9)
  #1      _rootRunUnary (dart:async/zone.dart:1198:47)
  #2      _CustomZone.runUnary (dart:async/zone.dart:1100:19)
  #3      _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
  #4      Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
  #5      Future._propagateToListeners (dart:async/future_impl.dart:725:32)
  #6      Future._completeWithValue (dart:async/future_impl.dart:529:5)
  #7      Future._asyncCompleteWithValue.&lt;anonymous closure&gt; (dart:async/future_impl.dart:567:7)
  #8      _rootRun (dart:async/zone.dart:1190:13)
  #9      _CustomZone.run (dart:async/zone.dart:1093:19)
  #10     _CustomZone.runGuarded (dart:async/zone.dart:997:7)
  #11     _CustomZone.bindCallbackGuarded.&lt;anonymous closure&gt; (dart:as&lt;…&gt;
  </code></pre>