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

Method handleError

Lib/logging/__init__.py:1060–1105  ·  view source on GitHub ↗

Handle errors which occur during an emit() call. This method should be called from handlers when an exception is encountered during an emit() call. If raiseExceptions is false, exceptions get silently ignored. This is what is mostly wanted for a logging syst

(self, record)

Source from the content-addressed store, hash-verified

1058 del _handlers[self._name]
1059
1060 def handleError(self, record):
1061 """
1062 Handle errors which occur during an emit() call.
1063
1064 This method should be called from handlers when an exception is
1065 encountered during an emit() call. If raiseExceptions is false,
1066 exceptions get silently ignored. This is what is mostly wanted
1067 for a logging system - most users will not care about errors in
1068 the logging system, they are more interested in application errors.
1069 You could, however, replace this with a custom handler if you wish.
1070 The record which was being processed is passed in to this method.
1071 """
1072 if raiseExceptions and sys.stderr: # see issue 13807
1073 exc = sys.exception()
1074 try:
1075 sys.stderr.write('--- Logging error ---\n')
1076 traceback.print_exception(exc, limit=None, file=sys.stderr)
1077 sys.stderr.write('Call stack:\n')
1078 # Walk the stack frame up until we're out of logging,
1079 # so as to print the calling context.
1080 frame = exc.__traceback__.tb_frame
1081 while (frame and os.path.dirname(frame.f_code.co_filename) ==
1082 __path__[0]):
1083 frame = frame.f_back
1084 if frame:
1085 traceback.print_stack(frame, file=sys.stderr)
1086 else:
1087 # couldn't find the right stack frame, for some reason
1088 sys.stderr.write('Logged from file %s, line %s\n' % (
1089 record.filename, record.lineno))
1090 # Issue 18671: output logging message and arguments
1091 try:
1092 sys.stderr.write('Message: %r\n'
1093 'Arguments: %s\n' % (record.msg,
1094 record.args))
1095 except RecursionError: # See issue 36272
1096 raise
1097 except Exception:
1098 sys.stderr.write('Unable to print the message and arguments'
1099 ' - possible formatting error.\nUse the'
1100 ' traceback above to help find the error.\n'
1101 )
1102 except OSError: #pragma: no cover
1103 pass # see issue 5971
1104 finally:
1105 del exc
1106
1107 def __repr__(self):
1108 level = getLevelName(self.level)

Callers 1

emitMethod · 0.45

Calls 4

print_exceptionMethod · 0.80
exceptionMethod · 0.45
writeMethod · 0.45
print_stackMethod · 0.45

Tested by

no test coverage detected