-
-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Include NSError code, domain and HTTP Status code in DarwinWebSocketException message #209
Include NSError code, domain and HTTP Status code in DarwinWebSocketException message #209
Conversation
Thanks a lot for the suggestion and the PR! The Do I understand correctly that your use case is not about getting information from the exception object (in code), but rather seeing a more informative message when it crashes? In that case I definitely agree we can change the error message in the way you did in the PR. The HTTP status code is slightly more debatable, because it only applies during the HTTP handshake for the upgrade to web socket protocol, but this exception is supposed to represent any error on the websocket. That said, we can be pragmatic and add it too, because it is indeed useful to debug connection issues (which in all honesty probably represent a significant proportion of all errors :D). |
...re/src/nativeDarwinMain/kotlin/org/hildan/krossbow/websocket/darwin/DarwinWebSocketClient.kt
Outdated
Show resolved
Hide resolved
...re/src/nativeDarwinMain/kotlin/org/hildan/krossbow/websocket/darwin/DarwinWebSocketClient.kt
Outdated
Show resolved
Hide resolved
...re/src/nativeDarwinMain/kotlin/org/hildan/krossbow/websocket/darwin/DarwinWebSocketClient.kt
Outdated
Show resolved
Hide resolved
@remy-bardou-lifeonair If you don't have time to discuss this, that's completely ok. Just let me know, because in this case I will merge this PR and make adjustments on top myself before releasing it |
no worries, it's just my email notifications are not setup properly so I hadn't seen your feedback yet! |
…eption and DarwinWebSocketHandshakeException
When something went wrong in the web socket handshake on iOS, it's hard to understand why.
That's because the description available with
DarwinWebSocketException
only comes fromNSError.localizedDescription
.Such example, when hitting a 401 error would be
There was a bad response from the server.
.NSError
has adomain
anderrorCode
available, that a developer can look up in the Apple documentation to get more context on. Furthermore, it is usually very helpful to know the HTTP Status code.So my proposal is to improve the exception text to include all those data points.
This was tested successfully on iOS by trying to connect to a web socket endpoint that requires authentication and not provide any headers.
I observed the following logs as a result:
NSURLErrorDomain -1011: There was a bad response from the server. (HTTP Status Code: 401)
, which see more actionable to me as a developer.