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