<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _cast_to_type(self, value):
 """ Convert the value to an int and raise error on failures"""

        try:
            return int(value)
        except (ValueError, TypeError):
            self.fail('invalid', value=value)