code: def test_show_json_with_error(dvc, mocker, capsys):
      cli_args = parse_args(["plots", "show", "--json"])
      cmd = cli_args.func(cli_args)
  
      e = YAMLFileCorruptedError("dvc.yaml")
      data = set_in({}, ["workspace", "definitions", "error"], e)
      cmd._func = mocker.MagicMock(return_value=data)
  
      cmd.run()
      out, _ = capsys.readouterr()
      assert json.loads(out) == {
          "errors": [
              {
                  "rev": "workspace",
                  "type": type(e).__name__,
                  "msg": e.args[0],
              }
          ]
      }
  
imports: import json
  import os
  import posixpath
  from pathlib import Path
  import pytest
  from funcy import set_in
  from dvc.cli import parse_args
  from dvc.commands.plots import CmdPlotsDiff, CmdPlotsShow, CmdPlotsTemplates
  from dvc.render.match import RendererWithErrors
  from dvc.utils.serialize import YAMLFileCorruptedError
label_desc: Use image node_id 15 for calling a global function with example usage: test_show_json_with_error(dvc, mocker, capsys) without return types