package lookup;

import com.twilio.Twilio;
import com.twilio.rest.lookups.v1.PhoneNumber;

public class Lookup {
    
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

    public static void main(String[] args) {
        if(args.length == 0) {
            throw new IllegalArgumentException("Missing command line argument.");
        }

        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        String lookup_number = args[0];

        PhoneNumber number = PhoneNumber
            .fetcher(new com.twilio.type.PhoneNumber(lookup_number))
            .setType("carrier")
            .fetch();

        System.out.println("Carrier name: " + number.getCarrier().get("name"));
        System.out.println("Number type: " + number.getCarrier().get("type"));
    }
}
@@ -530,16 +530,34 @@
 gs%5B0%5D;%0A%0A
+        try %7B%0A    
         
@@ -597,24 +597,28 @@
             
+   
+ 
 .fetcher(new
@@ -674,16 +674,20 @@
         
+    
 .setType
@@ -706,24 +706,28 @@
             
+    
 .fetch();%0A%0A 
@@ -725,32 +725,36 @@
 tch();%0A%0A        
+ 
+   
 System.out.print
@@ -809,32 +809,36 @@
 ame%22));%0A        
+    
 System.out.print
@@ -895,12 +895,137 @@
 %22));
+%0A%0A        %7D catch(com.twilio.exception.ApiException e) %7B%0A            System.out.println(%22Phone number not found.%22);%0A        %7D
 %0A    %7D%0A%7D
@@ -1024,8 +1024,9 @@
 %0A    %7D%0A%7D
+%0A

add error handling