-
Notifications
You must be signed in to change notification settings - Fork 656
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
KN: Wrapping NSError from NSURLSession in Exceptions #3307
Comments
Thanks for sending this. The hard part is that we want the API to be MPP as much as possible. Ideally we want an API that allows the code in |
Common logic for all platforms is good. But it is precisely for iOS that there is not enough opportunity to get the original NSError error, and this check will already be only from the iOS part. Currently, only message is reported in IOException - you can get it from any exception anyway. Example 1:
AppleIOException can be received and so only when running on ios - therefore, other platforms do not need to know about it, and for output in the common part of the message, it remains so. Example 2 (we use it in our project): commonMain:
appleMain:
In this example, we can use a wrapper on NSError in the common code, but it can only be created in the ios part. |
We could expose The current rationale is that If more fine grained UI logic is needed like for an example:
If the above fine-grained logic is needed for iOS, there's no reason it shouldn't be available on Android too. Do you have a list of Apple domain/codes you need to read? |
It is important for us to know not only that this is an ApolloNetworkException, but also the original exception that we take from cause. In Android and iOS, we use this knowledge to correctly display the message, depending on whether it is a connection problem or not. We also need the original error from the network client for logging in order to more accurately determine the original problem. For example, in Android, we determine the type of error this way, getting it from ApolloNetworkException.cause (jvmMain):
For iOS, we can also determine the type of error if we know the original one (appleMain):
Also, each platform has logging, in the case of android, the original exception is used, and in the case of ios, the original error with all the contents, including userInfo. It is no longer relevant to the question, but here is the current implementation of our final exception as example, which provides all the necessary information through an abstract class (commonMain):
Using AppleErrorPovider, we determine on the iOS (swift) side that there is an NSError for this exception and get it from AppleError. |
Many thanks for all the details. This is helpful. I can see how the errors do not always map 1:1 and having the original error allows more detailed diagnostics 👍 . I'll open a PR in a bit. |
Thank You! 👍 |
PR there: #3315 Let me know what you think. |
I looked at it - a good solution. Perhaps it would be good to add to appleMain extension:
In Android now available |
Good idea. I added I don't think Android needs anything else since |
Yes, the standard exception feature - cause is already available for android, because unlike ios, kotlin is based on jvm approaches. |
Tell me, when will the next alpha version be? |
Hopefully soon-ish :). Ideally there'll be some Java codegen for the next alpha but we can always do intermediate alphas if this ends up taking too long. Also, you can always use the SNAPSHOT. There's a |
Hi!
Now all the errors from NSURLSession received as an Apollo NetworkException, inside which an IOException is nested without the original NSError.
Because of this, I can't get the original NSError in iOS and work it out correctly, because I don't know its domain and code.
Please add the ability to get the original NSError object in all your exceptions, where they are.
The text was updated successfully, but these errors were encountered: