code: def error(msg: str, resource: Optional['Resource'] = None, stream_id: Optional[int] = None):
      
      engine = get_engine()
      if engine is not None:
          _log(engine, engine_pb2.ERROR, msg, resource, stream_id)
      else:
          print("error: " + msg, file=sys.stderr)
docs: Logs a message to the Pulumi CLI's error channel, associating it with a resource
      and stream_id if provided.
  
      :param str msg: The message to send to the Pulumi CLI.
      :param Optional[Resource] resource: If provided, associate this message with the given resource in the Pulumi CLI.
      :param Optional[int] stream_id: If provided, associate this message with a stream of other messages.