Eclipse will auto suggest the exceptions that might be thrown. Or you
can see the method signatures and check what king of exception do the
methods throw .

Thanks and Regards,
Kumar Bibek

On Apr 6, 2:51 pm, Anna PS <[email protected]> wrote:
> Hi all
>
> I'm using a PostMethod, and wondering what try/except handling I
> should use.
>
> The exception handling here seems to work okay in most scenarios, but
> is there anything I might be missing? In particular, I'm wondering
> whether this handles the network connection going down midway through
> the upload.
>
>                 PostMethod method;
>                 method = new PostMethod("blah/");
>                 try {
>                         Part[] parts = {
>                                         new StringPart("blah", blah),
>                                         file };
>                         method.setRequestEntity(new 
> MultipartRequestEntity(parts, method
>                                         .getParams()));
>                         try {
>                                 client.executeMethod(method);
>                         } catch (java.net.UnknownHostException uhe) {
>                                 //handle error
>                         }
>                   responseString = method.getResponseBodyAsString();
>                   int statusCode;
>                   try {
>                          statusCode = method.getStatusCode();
>                   } finally {
>                          statusCode = 0;
>                   }
>                   method.releaseConnection();
>                   if (statusCode == 200) {
>                                 //do stuff
>                   } else {
>                                 //do other stuff
>                   }
>                 } catch (Exception ex) {
>                         return false;
>                 } finally {
>                         method.releaseConnection();
>                 }

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

To unsubscribe, reply using "remove me" as the subject.

Reply via email to