Skip to content

Commit 122028c

Browse files
committed
Avoid ConfigError for failure to clear cache
1 parent 302571f commit 122028c

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

src/cjdk/_api.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@
1010
from typing import TYPE_CHECKING
1111

1212
from . import _cache, _conf, _index, _install, _jdk
13-
from ._exceptions import ConfigError, InstallError, UnsupportedFormatError
13+
from ._exceptions import (
14+
CjdkError,
15+
ConfigError,
16+
InstallError,
17+
UnsupportedFormatError,
18+
)
1419

1520
if TYPE_CHECKING:
1621
from collections.abc import Callable, Iterator
@@ -129,16 +134,16 @@ def clear_cache(**kwargs: Unpack[ConfigKwargs]) -> Path:
129134
130135
Raises
131136
------
132-
ConfigError
133-
If configuration is invalid.
137+
CjdkError
138+
If the cache directory could not be removed.
134139
"""
135140
conf = _conf.configure(**kwargs)
136141
cache_path = conf.cache_dir
137142
if cache_path.exists():
138143
try:
139144
shutil.rmtree(cache_path)
140145
except OSError as e:
141-
raise ConfigError(
146+
raise CjdkError(
142147
f"Failed to remove cache directory {cache_path}: {e}"
143148
) from e
144149
return cache_path

0 commit comments

Comments
 (0)