-
Notifications
You must be signed in to change notification settings - Fork 15
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
Access to native error / request error type to differentiate network errors #61
Comments
Hey! 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. |
Thanks for the answer. We cannot get the actual native error indeed, I meant the 'wrapped' Javascript version. On iOS the error returned by 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: