code: def test_4xx_exceptions_caught_in_subcommands(
      self, mock_api_handled_group, mock_subcommand, api_error_msg
  ):
      mock_subcommand.invoke = MagicMock(
          side_effect=ApiException(
              http_resp=HTTPResponse(
                  status=400,
                  reason="Bad Request",
                  body=dumps(
                      {
                          "code": 3,
                          "message": api_error_msg,
                          "details": [],
                      },
                  ),
              )
          )
      )
  
      runner = CliRunner()
      result = runner.invoke(
          mock_api_handled_group,
          [mock_subcommand.name],
          standalone_mode=False,  # stop runner from raising SystemExit on ClickException
      )
  
      mock_subcommand.invoke.assert_called
      assert result.exit_code == 1
      assert type(result.exception) is ClickException
      assert api_error_msg == str(result.exception)
  
file_path: pytorch-lightning/tests/tests_app/utilities/test_exceptions.py
imports: from json import dumps
  from unittest.mock import MagicMock
  import pytest
  from click import ClickException, group
  from click.testing import CliRunner
  from lightning.app.utilities.exceptions import _ApiExceptionHandler
  from lightning_cloud.openapi.rest import ApiException
  from urllib3 import HTTPResponse
label_desc: Use image node_id 1 for calling the Test_ApiExceptionHandler obj's underlying member method code with example usage: obj.test_4xx_exceptions_caught_in_subcommands(mock_api_handled_group, mock_subcommand, api_error_msg) without return types