You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I might have missed something, but it doesn't seem possible to retrieve the original / native errors thrown on iOS and Android by their respective networking libraries in order to determine whether the error is a network error, a timeout error or another kind of error.
Is there a way to get this information ? Or an easy way around the fact that errors returned by the @klippa/nativescript-http plugin are strings ?
For my use case, I managed to naively parse the returned strings and deduce the error but it turns out the iOS implementation returns an Error(error.localizedDescription) so parsing won't work in that case :)
Any tip would be much appreciated.
Thanks, great plugin otherwise !
The text was updated successfully, but these errors were encountered:
At this moment, I don't think it's possible to get the original native error. I'm also not sure whether NativeScript has something to provide in that. It's probably better to transform these errors in the plugin to standardized TypeScript errors.
I would accept Pull Requests for that.
We cannot get the actual native error indeed, I meant the 'wrapped' Javascript version.
On iOS the error returned by session.dataTaskWithRequestCompletionHandler(urlRequest, function (data, response, error) {...} seems to be a 'wrapped' Javascript NSError. On Android though, I'm not sure what errors are mapped to (probably some subclass of a java Exception ?).
I guess it would be somewhat complicated to map iOS NSErrors and Android Exceptions to various error types (no network, timeout etc...) but it might be nice to have a way to retrieve the 'original' (but not native :) ) error.
I'm not super familiar with TypeScript errors, but it looks like one would have to create a subclass for that ? (And add an nativeError / underlyingError property to the Error class).
I don't have a lot of time to delve more into this right now but may try to make a pull request later.
Hello, I might have missed something, but it doesn't seem possible to retrieve the original / native errors thrown on iOS and Android by their respective networking libraries in order to determine whether the error is a network error, a timeout error or another kind of error.
Is there a way to get this information ? Or an easy way around the fact that errors returned by the @klippa/nativescript-http plugin are strings ?
For my use case, I managed to naively parse the returned strings and deduce the error but it turns out the iOS implementation returns an
Error(error.localizedDescription)
so parsing won't work in that case :)Any tip would be much appreciated.
Thanks, great plugin otherwise !
The text was updated successfully, but these errors were encountered: