-1

I want to get all Tasks from this Java code. I get

com.podio.APIApplicationException: null

How I skip the code with NPE and continue the execution of the code?

import com.podio.APIFactory;
import com.podio.ResourceFactory;
import com.podio.api.Podio;
import com.podio.oauth.OAuthClientCredentials;
import com.podio.oauth.OAuthUsernameCredentials;
import com.podio.task.TaskAPI;

public class PodioImpl implements Podio
{
    @Override
    public void connect(String client_id, String secret, String user_name, String password)
    {
        ResourceFactory resourceFactory = new ResourceFactory(
            new OAuthClientCredentials(client_id, secret),
            new OAuthUsernameCredentials(user_name, password));
        APIFactory apiFactory = new APIFactory(resourceFactory);

        TaskAPI api1 = apiFactory.getAPI(TaskAPI.class);

        if(api1.getActiveTasks() != null){
            System.out.println("ActiveTasks ");
        }
        if(api1.getAssignedActiveTasks() != null){
            System.out.println("AssignedActiveTasks ");
        }
        if(api1.getCompletedTasks() != null){
            System.out.println("CompletedTasks ");
        }
    }
}
Bahramdun Adil
  • 5,907
  • 7
  • 35
  • 68
Peter Penzov
  • 1,126
  • 134
  • 430
  • 808

1 Answers1

0

This question was answered here, the title is not the same but the content is basically the same : Avoiding != null statements You will find the information you need in order to deal with your problem and several guidelines. It's a common problem.

Community
  • 1
  • 1
ArkDeus
  • 143
  • 9