docs: def setErrorHandler(self, errorhandler):
          """
          Sets a new error handler.
  
          Args:
              errorhandler: The object handling AMPL errors and warnings.
          """
          class ErrorHandlerWrapper(ErrorHandler):
              def __init__(self, errorhandler):
                  self.errorhandler = errorhandler
                  self.last_exception = None
  
              def error(self, exception):
                  if isinstance(exception, amplpython.AMPLException):
                      exception = AMPLException(exception)
                  try:
                      self.errorhandler.error(exception)
                  except Exception as e:
                      self.last_exception = e
  
              def warning(self, exception):
                  if isinstance(exception, amplpython.AMPLException):
                      exception = AMPLException(exception)
                  try:
                      self.errorhandler.warning(exception)
                  except Exception as e:
                      self.last_exception = e
  
              def check(self):
                  if self.last_exception is not None:
                      e, self.last_exception = self.last_exception, None
                      raise e
  
          errorhandler_wrapper = ErrorHandlerWrapper(errorhandler)
  
          class InnerErrorHandler(amplpython.ErrorHandler):
              def error(self, exception):
                  errorhandler_wrapper.error(exception)
  
              def warning(self, exception):
                  errorhandler_wrapper.warning(exception)
  
          self._errorhandler = errorhandler
          self._errorhandler_inner = InnerErrorHandler()
          self._errorhandler_wrapper = errorhandler_wrapper
          lock_and_call(
              lambda: self._impl.setErrorHandler(self._errorhandler_inner),
              self._lock
          )