Skip to content
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

Return text error #43

Open
speedfl opened this issue Aug 23, 2017 · 4 comments
Open

Return text error #43

speedfl opened this issue Aug 23, 2017 · 4 comments

Comments

@speedfl
Copy link

speedfl commented Aug 23, 2017

Hello,

I am using this plugin with ionic and it is working with promises.
The resolve is called on success callback and the reject on callback failure

Rejecting a promise with empty error could be problematic if we want to perform some logic. Here is an example:

private method() : Promise<boolean>{
return this.appAvailability.check("fb//")
.then(() => this.doSomething())
.catch(err => console.error(err))
}

Here we can see that if doSomething reject as well with "" we cannot perform logic.

Is it possible to add a text in the error:
Example: "app_not_available"

https://github.com/ohh2ahh/AppAvailability/blob/master/src/android/AppAvailability.java#L42

For IOS I don't know how it works...

@kashban
Copy link

kashban commented Sep 3, 2018

Not sure why it would throw an error at all if I just want to know yes or no (or true or false). In our case it is NOT an error if some app isn't present, it's just to determine if to take another road to update the app.

The Plugin could just return true or false and throw exceptions if some actually occurred. Which is the better software design anyways.

@speedfl
Copy link
Author

speedfl commented Sep 3, 2018

Agree.
App available or not is functional success response.
For me it is better compared to reject without text

@ohh2ahh
Copy link
Owner

ohh2ahh commented Sep 3, 2018

You could just use the „Old Approach“ described in README.md.

@kashban
Copy link

kashban commented Sep 4, 2018

That would be up to the Ionic Native Team then, because I proxy to this plugin through them:

https://ionicframework.com/docs/native/app-availability/

Unfortunately they don't use checkBool().

I also fail to see why you changed the original Android API semantics to something throwing an exception instead of returning a perfectly valid "false" value. Where's the benefit in that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants