So I've been sifting through example after example of android code,
and I see most web requests don't actually catch that many exceptions,
maybe because their path is hard coded so there is no room for user
error?

I'm still confused as the best way to exit my background task
gracefully if my get() method raises an exception, at the moment
getting anything but a force close just isn't happening

On 11 Nov, 18:43, Lee Jarvis <ljjar...@googlemail.com> wrote:
> I have the following code...
>
>         @Override
>         protected Void doInBackground(Void... unused) {
>                 Log.i(TAG, "invoking background thread");
>
>                         try {
>                                 mClient.get("http://thishostdoesntexist";);
>                         } catch (RuntimeException e) {
>                                 mActivity.onTaskError(e.getMessage());
>                         } catch (HttpResponseException e) {
>                                 mActivity.onTaskError(e.getMessage());
>                         } catch (ClientProtocolException e) {
>                                 mActivity.onTaskError(e.getMessage());
>                         } catch (UnknownHostException e) {
>                                 mActivity.onTaskError(e.getMessage());
>                         } catch (IOException e) {
>                                 mActivity.onTaskError(e.getMessage());
>                         }
>
>                 Log.i(TAG, "exiting background thread");
>                 return null;
>         }
>
> My mClient get method is a simple HttpClient execute with an output
> buffer to read the input stream, so it's very trivial. Everytime I
> execute this task UnknownHostException will be triggered which will in
> turn call onTaskError on my currect Activity, but I still get a
> RuntimeException, but I don't see why. Maybe it's because it's late
> and i've done about 12 hours of writing code so it's something simple
> I just can't see?
>
> What should I be looking for?
>
> Thanks in advance

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

Reply via email to