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

Try-catch bug #8

Open
incube8r opened this issue Sep 3, 2018 · 0 comments
Open

Try-catch bug #8

incube8r opened this issue Sep 3, 2018 · 0 comments

Comments

@incube8r
Copy link

incube8r commented Sep 3, 2018

For this code:

background.run(new Runnable() {
            @Override
            public void run() {
                try {
                    List<String> values= repository.get();
                    // stuff
                } catch (Exception e) {
                    Window.alert(e.getMessage()); 
                }
            }
        });

The exception is expected to be capture here and the alert should popup, but it does not if the repository code looks like this:

    public List<String> get() throws IOException {
        List<String> values= null;
        String body = null;
        body = ajaxCall();
        values = parse(body);
        return values;
    }

At this point the ajaxCall() did get a HTTP error but the exception did not propagate.
However, if we put the ajaxCall in a try-catch block the exception gets propagated above.

public List<String> get() {
    List<String> values= null;
    String body = null;
    try {
        body = ajaxCall();
        values = parse(body);
    } catch (IOException e) {
    }
    return values;
}

Shouldn't it be the reverse, since we already catch the exception in this code, then it should not propagate but what's happening is the reverse, is this a bug?

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