Skip to content

Commit b784644

Browse files
committed
Add exception handling
1 parent 0f30465 commit b784644

4 files changed

Lines changed: 17 additions & 2 deletions

File tree

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ it-depends "ubuntu:libc6@2.31"
7676
it-depends "npm:lodash@>=4.17.0"
7777
```
7878

79+
To list resolvers compatible for the specified target, use the `--list` option:
80+
81+
```shell
82+
it-depends . --list
83+
```
84+
7985
It-Depends will output the full dependency hierarchy in JSON format. Additional output formats such
8086
as Graphviz/Dot are available via the `--output-format` option.
8187

@@ -124,7 +130,7 @@ This is the resulting dependency graph:
124130
git clone https://github.com/trailofbits/it-depends
125131
cd it-depends
126132
make dev
127-
source .venv/bin/activate
133+
uv run it-depends --help
128134
```
129135

130136
Format and lint code before contributing

src/it_depends/_cli.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def parse_path_or_package_name(
3737
return dependency
3838

3939

40-
def main() -> None: # noqa: C901, PLR0912, PLR0915
40+
def main() -> None: # noqa: C901, PLR0912, PLR0915, PLR0911
4141
settings = Settings() # type: ignore[call-arg]
4242
setup_logger(settings.log_level)
4343

@@ -61,6 +61,11 @@ def main() -> None: # noqa: C901, PLR0912, PLR0915
6161
logger.exception(msg)
6262
return
6363

64+
# If this is a source repository, make sure the folder exists
65+
if isinstance(repo, SourceRepository) and not repo.path.exists():
66+
logger.error("The specified path does not exist: %s", repo.path)
67+
return
68+
6469
# Clear the database cache
6570
if settings.clear_cache:
6671
db_path = Path(settings.database)

src/it_depends/pip.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,9 @@ def resolve(self, dependency: Dependency) -> Iterator[Package]:
285285
recurse=False,
286286
)
287287
)
288+
except subprocess.CalledProcessError:
289+
log.exception("Error using JohnnyDep to resolve %s", dependency.package)
290+
return iter(())
288291
except ValueError as e:
289292
log.warning(str(e))
290293
return iter(())

src/it_depends/resolution.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ def resolve( # noqa: C901, PLR0912, PLR0915
164164
# Resolve from source repository
165165
found_source_package = False
166166
for resolver in resolvers():
167+
logger.debug("Trying to resolve %s using resolver %s", repo_or_spec, resolver.name)
167168
if resolver.can_resolve_from_source(repo_or_spec):
168169
source_package = resolver.resolve_from_source(repo_or_spec, cache=cache)
169170
if source_package is None:

0 commit comments

Comments
 (0)