Search code examples
android-annotations

Handling exception in background?


I found that I am forced to throw exception in a background thread:

@Background
void bootstrap() throws IOException {

    mProgressBar.setVisibility(View.VISIBLE);
    restClient.setBearerAuth(Auth.token);
    UserID userIdJsonn = restClient.getUserId();
    Auth.user_id= userIdJsonn.getUser_id();
    PhoenixPlug.getInstance().ini();
    mProgressBar.setVisibility(View.GONE);
}

Of course, I've got this error:

Error:(619, 5) error: org.androidannotations.annotations.Background annotated methods should not declare throwing any exception

So, what's the recommended way to handle such a case?


Solution

  • If you are using a background annotation, you have to catch the exception locally.