Skip to content

Details of thrown WebSocketException unavailable #1700

Closed
@fulstadev

Description

@fulstadev

I'm trying to establish a websocket connection, through the following code:

final WebSocketChannel channel = WebSocketChannel.connect(
          Uri.parse(
              'wss://ws.mywsexample.com/?user=${user}&auth=${auth}'),
        );

        print('connecting...');

        /// Await completion of the connection attempt
        try {
          await channel.ready;
        } on SocketException catch (e) {
          print(e.message);
        } on WebSocketChannelException catch (e) {
          print(StackTrace.current.toString());
          print(e.inner!.toString());
          print(e.message);
        } catch (e) {
          print(e.toString);
        }

Whenever I run this code in an iOS simulator, I get that the second catch clause (WebSocketChannelException) is entered. But the problem is that I am unable to get any details / insight about the thrown error, e.g.:

  • print(e.message) simply gives Instance of 'WebSocketException'
  • print(e.inner.toString()) gives the same
  • The stack trace delivers the same, simply with the additional info of my function running the code above

This is not very helpful for debugging; how can I check the actual details of the thrown Exception? I can't even find any WebSocketException class in the package source?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions