soernt / signalr_client

A Flutter SignalR Client for ASP.NET Core
MIT License
131 stars 203 forks source link

It is not possible to use hubConnection.start().then(onValue, onError) #26

Open bart1998 opened 4 years ago

bart1998 commented 4 years ago

When i try to use hubConnection.start().then() and i let it connect to a non-existent server (causes an error offcourse) the application crashes with the following error:

Unhandled Exception: type 'GeneralError' is not a subtype of type 'Error' in type cast

This happends in the file hub_connection.dart on line 244.

https://github.com/soernt/signalr_client/blob/288cb3703fb83004b625c2e717e0daa035f53cb2/lib/hub_connection.dart#L244

This line tries to cast the error to the type 'Error'. As a lot of the errors in this library are of type 'GeneralError', that fails. As far as i know there is no reason that it casts to 'Error' as the same function is called with the type 'GeneralError' just a few lines above it.

https://github.com/soernt/signalr_client/blob/288cb3703fb83004b625c2e717e0daa035f53cb2/lib/hub_connection.dart#L236-L238

A fix for this would be to remove the cast in line 244 of hub_connection.dart. Like this:

completer.completeError(error);