MCPcopy Index your code
hub / github.com/RustPython/RustPython / _raise_error

Method _raise_error

Lib/_pydecimal.py:4002–4022  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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"""

Callers 15

create_decimalMethod · 0.95
__new__Method · 0.80
_check_nansMethod · 0.80
_compare_check_nansMethod · 0.80
__add__Method · 0.80
__mul__Method · 0.80
__truediv__Method · 0.80
_divideMethod · 0.80
__divmod__Method · 0.80
__mod__Method · 0.80
remainder_nearMethod · 0.80
__floordiv__Method · 0.80

Calls 3

errorFunction · 0.70
getMethod · 0.45
handleMethod · 0.45

Tested by 1

raise_errorMethod · 0.64