Skip to content

DartCode thinks the SocketException is uncaught even though the try-catch works as expected #2085

Closed

Description

@MateusRodCosta

Hello, I am having issue with the following method:

  Future<void> initialSync() async {
    _isLoading = true;
    notifyListeners();
    try {
      final result = await http.read('https://vip.aersia.net/roster.xml');

      _trackList = PlaylistXmlUtils.parseData(result);
      _isSuccess = true;
    } catch (ex) {
      _isSuccess = false;
    } finally {
      _isLoading = false;
      notifyListeners();
    }
  }

I parse a xml from a remote server to have a list of tracks. However I wanna show a error message if it fails either parsing the xml or if it can't even get the xml.

So, for my testing I run that method with wifi turned off.

When I run the code with the breakpoints in Uncaught Exceptions options enabled I always get:

Exception has occurred.
SocketException (SocketException: Failed host lookup: 'vip.aersia.net' (OS Error: No address associated with hostname, errno = 7))

As seen here:
Screenshot from 2019-11-02 13-39-41

However after I press "Step Into" enough times to get rid of the Uncaught Exception message I get the following:

Screenshot from 2019-11-02 13-43-00

Which simply appears to mean that the exception was actually caught.

Activity

  1. DanTup commented on Nov 4, 2019

    @DanTup
    Member

    Thanks for the report! There's an existing issue about this at #2063 so I'll close this one as a dupe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions