json - Getting the error code message in twitter api request (java) -


i'm trying use twitter api in following way:

string urladd = "https://api.twitter.com/1/following/ids.json?user_id=1000123"; url url = new url(urladd); urlconnection urlconnection = url.openconnection(); bufferedreader in = new bufferedreader(new inputstreamreader(urlconnection.getinputstream())); 

getinputstream input stream throws ioexception, happens because i've reached request limit. want able distinghuish between request limit error , other errors. twitter returns error message in json format, can't read because of thrown exception.

any ideas on how can fetch error message?

i found way it:

string urladd = "https://api.twitter.com/1/following/ids.json?user_id=1000123"; url url = new url(urladd); urlconnection urlconnection = url.openconnection(); httpurlconnection httpconn = (httpurlconnection)urlconnection; inputstream is; if (httpconn.getresponsecode() >= 400) {     = httpconn.geterrorstream(); } else {     = httpconn.getinputstream(); } bufferedreader in = new bufferedreader(new inputstreamreader(is)); 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -