Handles an error If the flag is in _ignored_flags, returns the default response. Otherwise, it sets the flag, then, if the corresponding trap_enabler is set, it reraises the exception. Otherwise, it returns the default value after setting the flag.
(self, condition, explanation = None, *args)
| 4000 | __copy__ = copy |
| 4001 | |
| 4002 | def _raise_error(self, condition, explanation = None, *args): |
| 4003 | """Handles an error |
| 4004 | |
| 4005 | If the flag is in _ignored_flags, returns the default response. |
| 4006 | Otherwise, it sets the flag, then, if the corresponding |
| 4007 | trap_enabler is set, it reraises the exception. Otherwise, it returns |
| 4008 | the default value after setting the flag. |
| 4009 | """ |
| 4010 | error = _condition_map.get(condition, condition) |
| 4011 | if error in self._ignored_flags: |
| 4012 | # Don't touch the flag |
| 4013 | return error().handle(self, *args) |
| 4014 | |
| 4015 | self.flags[error] = 1 |
| 4016 | if not self.traps[error]: |
| 4017 | # The errors define how to handle themselves. |
| 4018 | return condition().handle(self, *args) |
| 4019 | |
| 4020 | # Errors should only be risked on copies of the context |
| 4021 | # self._ignored_flags = [] |
| 4022 | raise error(explanation) |
| 4023 | |
| 4024 | def _ignore_all_flags(self): |
| 4025 | """Ignore all flags, if they are raised""" |