try wrapping it in an if with a guard that evaluates to true.

kris

On Wed, May 23, 2012 at 12:36 PM, Francisco M. Marzoa Alonso
<fmmar...@gmail.com> wrote:
> Hi and thanks by your fast answer,
>
> If I try to throw an exception that way just after AssetFileDescriptor
> ... line, Eclipse complains about Unreachable code.
>
> Regards,
>
> On 23/05/12 17:30, Justin Anderson wrote:
>> Just throw a new IOException...
>>
>> Thanks,
>> Justin Anderson
>> MagouyaWare Developer
>> http://sites.google.com/site/magouyaware
>>
>>
>> On Wed, May 23, 2012 at 9:26 AM, Francisco M. Marzoa Alonso <
>> fmmar...@gmail.com> wrote:
>>
>>> Hi there,
>>>
>>> Just for debugging my code I rather like to simulate the case an
>>> exception is raised, and I do not know how to do it.
>>>
>>> The code is the following:
>>>
>>>        try {
>>>            AssetFileDescriptor assetDescriptor = assets.openFd(filename);
>>>            return new AndroidMusic(assetDescriptor);
>>>        } catch (IOException e) {
>>>            throw new RuntimeException("Couldn't load music '" +
>>> filename + "'");
>>>        }
>>>
>>> What I want to do is to force the IOException after
>>>
>>> AssetFileDescriptor assetDescriptor = assets.openFd(filename);
>>>
>>> So the code goes into the catch block.
>>>
>>> How could I do that?
>>>
>>> Thanks a lot 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
>
> --
> 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

-- 
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