code: def test_httperror(app, client, kwargs):
      @app.get("/foo")
      def foo():
          raise HTTPError(400, **kwargs)
  
      @app.get("/bar")
      def bar():
          raise HTTPError
  
      rv = client.get("/foo")
      assert rv.status_code == 400
      if "message" not in kwargs:
          assert rv.json["message"] == "Bad Request"
      else:
          assert rv.json["message"] == "bad"
      if "detail" not in kwargs:
          assert rv.json["detail"] == {}
      else:
          assert rv.json["detail"] == {"location": "json"}
      if "headers" in kwargs:
          assert rv.headers["X-FOO"] == "bar"
  
      # test default error status code
      rv = client.get("/bar")
      assert rv.status_code == 500
      assert rv.json["message"] == "Internal Server Error"
      assert rv.json["detail"] == {}
  
file_path: apiflask/tests/test_exceptions.py
imports: import pytest
  from apiflask.exceptions import abort
  from apiflask.exceptions import HTTPError
label_desc: Use image node_id 1 for calling a global function with example usage: test_httperror(app, client, kwargs) without return types