code: def test_run_build_error_event(self, site_dir):
      build_errors = []
  
      class PluginRaisingError(plugins.BasePlugin):
          def __init__(self, error_on):
              self.error_on = error_on
  
          def on_pre_page(self, page, **kwargs):
              if self.error_on == "pre_page":
                  raise BuildError("pre page error")
              return page
  
          def on_page_markdown(self, markdown, **kwargs):
              if self.error_on == "page_markdown":
                  raise BuildError("page markdown error")
              return markdown
  
          def on_page_content(self, html, **kwargs):
              if self.error_on == "page_content":
                  raise PluginError("page content error")
              return html
  
          def on_post_page(self, html, **kwargs):
              if self.error_on == "post_page":
                  raise ValueError("post page error")
  
          def on_build_error(self, error, **kwargs):
              build_errors.append(error)
  
      cfg = load_config(site_dir=site_dir)
      cfg.plugins["errorplugin"] = PluginRaisingError(
          error_on="pre_page"
      )
      with self.assertLogs("mkdocs", level="ERROR"):
          self.assertRaises(Abort, build.build, cfg)
  
      cfg = load_config(site_dir=site_dir)
      cfg.plugins["errorplugin"] = PluginRaisingError(
          error_on="page_markdown"
      )
      with self.assertLogs("mkdocs", level="ERROR"):
          self.assertRaises(Abort, build.build, cfg)
  
      cfg = load_config(site_dir=site_dir)
      cfg.plugins["errorplugin"] = PluginRaisingError(
          error_on="page_content"
      )
      with self.assertLogs("mkdocs", level="ERROR"):
          self.assertRaises(Abort, build.build, cfg)
  
      cfg = load_config(site_dir=site_dir)
      cfg.plugins["errorplugin"] = PluginRaisingError(
          error_on="post_page"
      )
      with self.assertLogs("mkdocs", level="ERROR"):
          self.assertRaises(ValueError, build.build, cfg)
  
      cfg = load_config(site_dir=site_dir)
      cfg.plugins["errorplugin"] = PluginRaisingError(error_on="")
      build.build(cfg)
  
      self.assertEqual(len(build_errors), 4)
      self.assertIs(build_errors[0].__class__, BuildError)
      self.assertEqual(str(build_errors[0]), "pre page error")
      self.assertIs(build_errors[1].__class__, BuildError)
      self.assertEqual(str(build_errors[1]), "page markdown error")
      self.assertIs(build_errors[2].__class__, PluginError)
      self.assertEqual(str(build_errors[2]), "page content error")
      self.assertIs(build_errors[3].__class__, ValueError)
      self.assertEqual(str(build_errors[3]), "post page error")
  
imports: from __future__ import annotations
  import os
  import unittest
  from typing import TYPE_CHECKING, Optional
  from mkdocs import plugins
  from mkdocs.commands import build
  from mkdocs.config import base
  from mkdocs.config import config_options
  from mkdocs.config.base import ValidationError
  from mkdocs.exceptions import Abort, BuildError, PluginError
  from mkdocs.tests.base import load_config, tempdir
label_desc: Use image node_id 12 for calling the TestPluginCollection obj's underlying member method code with example usage: obj.test_run_build_error_event(site_dir) and returns: page, markdown, html