diff --git a/CHANGELOG.md b/CHANGELOG.md
index 42be033..f21e4fd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,7 @@
 
 - add new subcommand "password" for checking a single password
 - add pdb++ to dev dependencies
+- add some basic error handling
 
 ## 0.2.0 (02.11.2019)
 
diff --git a/hibpcli/cli.py b/hibpcli/cli.py
index d82084e..41240b5 100644
--- a/hibpcli/cli.py
+++ b/hibpcli/cli.py
@@ -1,5 +1,6 @@
 import click
 
+from hibpcli.exceptions import ApiError
 from hibpcli.keepass import check_passwords_from_db
 from hibpcli.password import Password
 
@@ -23,29 +24,36 @@ def keepass(path, password):
          password = click.prompt(
             "Please enter the master password for the database", hide_input=True
         )
-    # needs error handling
-    rv = check_passwords_from_db(path=path, master_password=password)
-    if rv:
-        click.echo("The passwords of following entries are leaked:")
-        click.echo(rv)
+    try:
+        rv = check_passwords_from_db(path=path, master_password=password)
+    except ApiError as e:
+        click.echo(str(e))
     else:
-        click.echo("Hooray, everything is safe!")
+        if rv:
+            click.echo("The passwords of following entries are leaked:")
+            click.echo(rv)
+        else:
+            click.echo("Hooray, everything is safe!")
 
 
 @click.command()
 @click.option('--password', default=None, help='Password which should be checked.')
 def password(password):
     """Check a single password."""
-    #breakpoint()
     if password is None:
          password = click.prompt(
             "Please enter a password which should be checked", hide_input=True
         )
     p = Password(password)
-    if p.is_leaked():
-        click.echo("Please change your password!")
+    try:
+        is_leaked = p.is_leaked()
+    except ApiError as e:
+        click.echo(str(e))
     else:
-        click.echo("Your password is safe!")
+        if is_leaked:
+            click.echo("Please change your password!")
+        else:
+            click.echo("Your password is safe!")
 
 main.add_command(keepass)
 main.add_command(password)
diff --git a/hibpcli/exceptions.py b/hibpcli/exceptions.py
new file mode 100644
index 0000000..d71d7bd
--- /dev/null
+++ b/hibpcli/exceptions.py
@@ -0,0 +1,5 @@
+class HibpError(Exception):
+    pass
+
+class ApiError(HibpError):
+    pass
\ No newline at end of file
diff --git a/hibpcli/password.py b/hibpcli/password.py
index 52aec95..5b9ce80 100644
--- a/hibpcli/password.py
+++ b/hibpcli/password.py
@@ -1,5 +1,8 @@
 import hashlib
 import httpx
+import socket
+
+from hibpcli.exceptions import ApiError
 
 
 class Password:
@@ -9,15 +12,19 @@ class Password:
     def is_leaked(self):
         hex_digest = self._generate_hash()
         first_hash_part, second_hash_part = hex_digest[:5], hex_digest[5:]
-        result = httpx.get(
-            f"https://api.pwnedpasswords.com/range/{first_hash_part}"
-        ).text
-        # the result is text with entries split by new line
-        # one entry consists of the rest of the hash and count of
-        # leak, separated by a colon
-        # cut off string - information after the hash is of no interest
-        partial_hash_list = [line[:35] for line in result.splitlines()]
-        return second_hash_part in partial_hash_list
+        try:
+            result = httpx.get(
+                f"https://api.pwnedpasswords.com/range/{first_hash_part}"
+            ).text
+        except socket.gaierror as e:
+            raise ApiError("Error: Could not get a result from the API.")
+        else:
+            # the result is text with entries split by new line
+            # one entry consists of the rest of the hash and count of
+            # leak, separated by a colon
+            # cut off string - information after the hash is of no interest
+            partial_hash_list = [line[:35] for line in result.splitlines()]
+            return second_hash_part in partial_hash_list
 
     def _generate_hash(self):
         hash_object = hashlib.sha1(bytes(self.password, "UTF-8"))

Catch network/API errors
**current behaviour**
When the hibp API is not available, the user gets a nasty traceback.

**wished behaviour**
When the hibp API is not available, the user gets a decent error message.
diff --git a/tests/test_cli.py b/tests/test_cli.py
index d58f909..0f28614 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -4,6 +4,7 @@ from click.testing import CliRunner
 from unittest.mock import patch
 
 from hibpcli.cli import main
+from hibpcli.exceptions import ApiError
 from hibpcli.password import Password
 
 
@@ -98,3 +99,24 @@ def test_password_subcommand_with_prompt(mock_password):
         Your password is safe!
     """
     assert result.output == textwrap.dedent(expected_output)
+
+
+@patch.object(Password,"is_leaked")
+def test_keepass_subcommand_error_handling(mock_password):
+    mock_password.side_effect = ApiError("Error")
+    runner = CliRunner()
+    result = runner.invoke(
+        main, ["keepass", "--path", "tests/test.kdbx", "--password", "test"]
+    )
+    expected_output = "Error\n"
+    assert result.output == expected_output
+
+
+@patch.object(Password, "is_leaked", side_effect=ApiError("Error"))
+def test_password_subcommand_error_handling(mock_password):
+    runner = CliRunner()
+    result = runner.invoke(
+        main, ["password", "--password", "test"]
+    )
+    expected_output = "Error\n"
+    assert result.output == expected_output
diff --git a/tests/test_password.py b/tests/test_password.py
index e218f07..7878b1b 100644
--- a/tests/test_password.py
+++ b/tests/test_password.py
@@ -1,7 +1,9 @@
 import pytest
+import socket
 
 from unittest.mock import patch
 
+from hibpcli.exceptions import ApiError
 from hibpcli.password import Password
 
 # this is just a small part of a real response
@@ -19,3 +21,11 @@ def test_is_leaked_password(mock_get):
     p = Password("test")
     assert p.is_leaked() is True
     mock_get.assert_called_with("https://api.pwnedpasswords.com/range/A94A8")
+
+
+@patch("hibpcli.password.httpx.get")
+def test_is_leaked_raises_api_error(mock_get):
+    mock_get.side_effect = socket.gaierror
+    p = Password("test")
+    with pytest.raises(ApiError):
+        p.is_leaked()

pip install -e .[dev]
parse_log_pytest
pytest
pytest pytest-cov
pip install --upgrade pip
3.7
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
argon2-cffi==23.1.0
argon2-cffi-bindings==21.2.0
attrs @ file:///croot/attrs_1668696182826/work
certifi @ file:///croot/certifi_1671487769961/work/certifi
cffi==1.15.1
chardet==3.0.4
Click==7.0
construct==2.10.70
coverage==7.2.7
fancycompleter==0.9.1
flit_core @ file:///opt/conda/conda-bld/flit-core_1644941570762/work/source/flit_core
future==1.0.0
h11==0.8.1
h2==3.2.0
-e git+https://github.com/jugmac00/hibpcli.git@62c364e78c4924dbb98ebf8a3b124834faeb0316#egg=hibpcli
hpack==3.0.0
hstspreload==2025.1.1
httpx==0.7.5
hyperframe==5.2.0
idna==2.10
importlib-metadata @ file:///tmp/build/80754af9/importlib-metadata_1648562407465/work
iniconfig @ file:///home/linux1/recipes/ci/iniconfig_1610983019677/work
lxml==5.3.1
packaging @ file:///croot/packaging_1671697413597/work
pdbpp==0.10.3
pluggy @ file:///tmp/build/80754af9/pluggy_1648042572264/work
py @ file:///opt/conda/conda-bld/py_1644396412707/work
pycparser==2.21
pycryptodome==3.22.0
Pygments==2.17.2
pykeepass==3.1.1
pyrepl==0.9.0
pytest==7.1.2
pytest-cov==4.1.0
python-dateutil==2.9.0.post0
rfc3986==1.5.0
six==1.17.0
tomli @ file:///opt/conda/conda-bld/tomli_1657175507142/work
typing_extensions @ file:///croot/typing_extensions_1669924550328/work
wmctrl==0.5
zipp @ file:///croot/zipp_1672387121353/work

name: hibpcli
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
  - attrs=22.1.0=py37h06a4308_0
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2022.12.7=py37h06a4308_0
  - flit-core=3.6.0=pyhd3eb1b0_0
  - importlib-metadata=4.11.3=py37h06a4308_0
  - importlib_metadata=4.11.3=hd3eb1b0_0
  - iniconfig=1.1.1=pyhd3eb1b0_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=1.1.1w=h7f8727e_0
  - packaging=22.0=py37h06a4308_0
  - pluggy=1.0.0=py37h06a4308_1
  - py=1.11.0=pyhd3eb1b0_0
  - pytest=7.1.2=py37h06a4308_0
  - python=3.7.16=h7a1cb2a_0
  - readline=8.2=h5eee18b_0
  - setuptools=65.6.3=py37h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tomli=2.0.1=py37h06a4308_0
  - typing_extensions=4.4.0=py37h06a4308_0
  - wheel=0.38.4=py37h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zipp=3.11.0=py37h06a4308_0
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - argon2-cffi==23.1.0
      - argon2-cffi-bindings==21.2.0
      - cffi==1.15.1
      - chardet==3.0.4
      - click==7.0
      - construct==2.10.70
      - coverage==7.2.7
      - fancycompleter==0.9.1
      - future==1.0.0
      - h11==0.8.1
      - h2==3.2.0
      - hibpcli==0.2.0
      - hpack==3.0.0
      - hstspreload==2025.1.1
      - httpx==0.7.5
      - hyperframe==5.2.0
      - idna==2.10
      - lxml==5.3.1
      - pdbpp==0.10.3
      - pip==24.0
      - pycparser==2.21
      - pycryptodome==3.22.0
      - pygments==2.17.2
      - pykeepass==3.1.1
      - pyrepl==0.9.0
      - pytest-cov==4.1.0
      - python-dateutil==2.9.0.post0
      - rfc3986==1.5.0
      - six==1.17.0
      - wmctrl==0.5
prefix: /opt/conda/envs/hibpcli

tests/test_cli.py::test_keepass_subcommand_returns_leaked_entry tests/test_cli.py::test_keepass_subcommand_returns_all_ok tests/test_cli.py::test_keepass_subcommand_with_path_option tests/test_cli.py::test_keepass_subcommand_with_path_and_password_options tests/test_cli.py::test_password_subcommand_for_leaked_password tests/test_cli.py::test_password_subcommand_for_safe_password tests/test_cli.py::test_password_subcommand_with_prompt tests/test_cli.py::test_keepass_subcommand_error_handling tests/test_cli.py::test_password_subcommand_error_handling tests/test_password.py::test_password_signature tests/test_password.py::test_is_leaked_password tests/test_password.py::test_is_leaked_raises_api_error
hibpcli/cli.py hibpcli/exceptions.py CHANGELOG.md hibpcli/password.py
hibpcli/cli.py hibpcli/exceptions.py CHANGELOG.md hibpcli/password.py