My code looks like this:

```
cIndex = (int)rand.Next(App.viewablePhrases.Count);
phrase = App.viewablePhrases[cIndex];

```

Infrequently it's giving me an error:

```
Application Specific Information:
*** Terminating app due to uncaught exception 'SIGABRT', reason: 'Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index'

Xamarin Exception Stack:
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
  at System.Collections.Generic.List`1[T].get_Item (System.Int32 ) <0x10047bfc0 + 0x0007b> in <939d99b14d934342858948926287beba#d346c1f46aec0f7ce096300b9d7adc79>:0
  at CardsTabViewModel.Random () <0x10138a5d0 + 0x0013b> in <1a94c4e2e6ff49bab0334b2d6333fc29#d346c1f46aec0f7ce096300b9d7adc79>:0

```

Is there a way I could catch this exception to show more details?
['https://Stackoverflow.com/questions/58505500', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1422604/']
> 
> Is there a way I could catch this exception to show more details?
> 
> 
> 

Just put your code in try / catch block like this:

```
try
{
 cIndex = (int)rand.Next(App.viewablePhrases.Count);
 phrase = App.viewablePhrases[cIndex];
}
catch(System.ArgumentOutOfRangeException e)
{
  Console.WriteLine("Exception information: {0}", e);
}
catch(Exception e)
{
  Console.WriteLine("Exception information: {0}", e);
}

```

Set a break point in catch block to see more information.
Index can be from 0 to Count-1.