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

How to get statusCode from try/catch on sync request #143

Open
cutiko opened this issue Jun 2, 2016 · 0 comments
Open

How to get statusCode from try/catch on sync request #143

cutiko opened this issue Jun 2, 2016 · 0 comments

Comments

@cutiko
Copy link

cutiko commented Jun 2, 2016

Greetings

Im following the doc about the sync request https://github.com/orhanobut/wasp/wiki/Sync-Request is working. But I cant figure it out how to handle the try/catch properly.

First I realize that any error would crash the app. So according with documentation "Use try/catch block to handle exceptions". Off course the try/catch rescue the app from crashing, but I cant know what is the error number. So I added the Callback inside the try/catch, very silly of me cause the try/catch handle the exception first, hence the callback is never executed.

I have being looking at the library classes to understand how to handle the error. By example the Callback lead me to a dead end cause is an Interface. The WaspError gave me some clues, but Im still bouncing.

How can I get the getStatusCode? This is what I have done so far:

try {
    User user = service.login();
}catch (RuntimeException exception) {
    Log.d("ERROR", exception.getCause().toString() + " " + exception.getLocalizedMessage() + " " + exception.getMessage() + " " + exception.getCause().getMessage());
}

What I need is something like what is done with the Callbacks:

@Override
public void onError(WaspError error) {
    //This is what I need
    error.getResponse().getStatusCode();
}

If I could get any help please, thanks.

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

1 participant