<p>I'm getting an exception which says "Access Denied" when the users permissions are sufficient, how do I catch an exception and check for "Access Denied" so that I can show the user a friendlier "Sorry Access Denied" message?</p>

<p>Thanks
Beginner :-)</p>

If you are using a try catch block...
```
```
try
{
    //error occurs
}
catch (Exception ex)
{
    MessageBox.show(ex.Message);
}
```
```
Obviously that is pretty crappy error handling, but it shows that the Exception object contains the error string.  You can narrow down the handling of different exceptions by catching different exception types.
```
```
Try
{
    //error occurs
}
catch (AccessDeniedException ex)
{
    MessageBox.show(ex.Message);
}
catch (FieldAccessException)
{

}
// etc...
```
```