diff --git a/gabbi/handlers.py b/gabbi/handlers.py
index d39a987..0b7a71d 100644
--- a/gabbi/handlers.py
+++ b/gabbi/handlers.py
@@ -128,9 +128,9 @@ class HeadersResponseHandler(ResponseHandler):
         try:
             response_value = response[header]
         except KeyError:
-            # Reform KeyError to something more debuggable.
-            raise KeyError("'%s' header not available in response keys: %s"
-                           % (header, response.keys()))
+            raise AssertionError(
+                "'%s' header not present in response: %s" % (
+                    header, response.keys()))
 
         if header_value.startswith('/') and header_value.endswith('/'):
             header_value = header_value.strip('/').rstrip('/')

missing response header raises error rather than failure
The following reports an error when it should report a failure instead:

```yaml
tests:

  - name: failure
    url: http://google.com

    status: 302
    response_headers:
        x-foo: bar
```

AFAICT that's because internally a `KeyError` is raised ("'x-foo' header not available in response keys: dict_keys(...)"): `testtools.TestCase`'s default `exception_handlers` doesn't have a mapping for that particular exception, so it defaults to `_report_error` rather than using `_report_failure`.

diff --git a/gabbi/tests/test_handlers.py b/gabbi/tests/test_handlers.py
index b647e80..af27359 100644
--- a/gabbi/tests/test_handlers.py
+++ b/gabbi/tests/test_handlers.py
@@ -133,9 +133,9 @@ class HandlersTest(unittest.TestCase):
             'location': '/somewhere',
         }}
         self.test.response = {'content-type': 'application/json'}
-        with self.assertRaises(KeyError) as failure:
+        with self.assertRaises(AssertionError) as failure:
             self._assert_handler(handler)
-        self.assertIn("'location' header not available in response keys:",
+        self.assertIn("'location' header not present in response:",
                       str(failure.exception))
 
     def _assert_handler(self, handler):

pip install -e .
parse_log_pytest
requirements.txt
pytest pytest-cov pytest-xdist pytest-mock pytest-asyncio
apt-get update apt-get install -y gcc
3.9
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
coverage==7.8.0
decorator==5.2.1
exceptiongroup==1.2.2
execnet==2.1.1
-e git+https://github.com/cdent/gabbi.git@081a75f5f0ddfdc31c4bab62db2f084a50c9ee99#egg=gabbi
httplib2==0.22.0
iniconfig==2.1.0
jsonpath-rw==1.4.0
packaging==24.2
pbr==6.1.1
pluggy==1.5.0
ply==3.11
pyparsing==3.2.3
pytest==8.3.5
pytest-asyncio==0.26.0
pytest-cov==6.0.0
pytest-mock==3.14.0
pytest-xdist==3.6.1
PyYAML==6.0.2
six==1.17.0
testtools==2.7.2
tomli==2.2.1
typing_extensions==4.13.0
wsgi_intercept==1.13.1

name: gabbi
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - coverage==7.8.0
      - decorator==5.2.1
      - exceptiongroup==1.2.2
      - execnet==2.1.1
      - httplib2==0.22.0
      - iniconfig==2.1.0
      - jsonpath-rw==1.4.0
      - packaging==24.2
      - pbr==6.1.1
      - pluggy==1.5.0
      - ply==3.11
      - pyparsing==3.2.3
      - pytest==8.3.5
      - pytest-asyncio==0.26.0
      - pytest-cov==6.0.0
      - pytest-mock==3.14.0
      - pytest-xdist==3.6.1
      - pyyaml==6.0.2
      - six==1.17.0
      - testtools==2.7.2
      - tomli==2.2.1
      - typing-extensions==4.13.0
      - wsgi-intercept==1.13.1
prefix: /opt/conda/envs/gabbi

gabbi/tests/test_handlers.py::HandlersTest::test_response_headers_fail_header
gabbi/tests/test_handlers.py::HandlersTest::test_response_headers gabbi/tests/test_handlers.py::HandlersTest::test_response_headers_fail_data gabbi/tests/test_handlers.py::HandlersTest::test_response_headers_regex gabbi/tests/test_handlers.py::HandlersTest::test_response_json_paths gabbi/tests/test_handlers.py::HandlersTest::test_response_json_paths_fail_data gabbi/tests/test_handlers.py::HandlersTest::test_response_json_paths_fail_path gabbi/tests/test_handlers.py::HandlersTest::test_response_strings gabbi/tests/test_handlers.py::HandlersTest::test_response_strings_fail
gabbi/handlers.py
gabbi/handlers.py