joshmarshall/mogo — Issue #6: Missing Fields Error Reporting
Author: hiwaylon
Created: 2011-11-02 16:35:58+00:00
State: open

### Description
Accessing ignored fields raises cryptic errors.

### Details
When ignored fields (named with an `_`) are accessed, a `KeyError` is raised. This exception should be more helpful, e.g. `InvalidFieldError` or possibly `AccessingIgnoredFieldError` in this case.

### Example
```python
class SomeModel(mogo.Model):
_secret = mogo.Field(dict, required=True, default=dict)

def do_secret_stuff(self):
my_model._secret.get("stuff", "")
```

Will produce:

```
mogo/mogo/field.py line 31 in __get__
value = self._get_value(instance)
mogo/mogo/field.py line 41 in _get_value
field_name = self._get_field_name(instance)
mogo/mogo/field.py line 37 in _get_field_name
return fields[self.id]
KeyError: 37806672
```