Skip to content

Commit

Permalink
Use error messages instead of NPE (#115)
Browse files Browse the repository at this point in the history
* repo: Use error messages instead of NPE when package cannot be found in MiraiRepo

* repo: use Local Variable Type Inference
  • Loading branch information
xtyuns committed Jun 2, 2022
1 parent c86d10b commit f716a26
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .gitignore
Expand Up @@ -4,3 +4,8 @@ build
out

/testing


/gradle
gradlew
gradlew.bat
10 changes: 9 additions & 1 deletion src/main/java/org/itxtech/mcl/module/builtin/Repo.java
Expand Up @@ -77,8 +77,16 @@ public void cli() {

if (loader.cli.hasOption("i")) {
var pkg = loader.cli.getOptionValue("i");

loader.logger.info("Fetching channel info for package \"" + pkg + "\"");
for (var chan : loader.repo.fetchPackage(pkg).channels.entrySet()) {
var fetchedPackageInfo = loader.repo.fetchPackage(pkg);
if (null == fetchedPackageInfo) {
loader.logger.error("Package \"" + pkg + "\" is not found in MiraiRepo");
loader.exit(1);
return;
}

for (var chan : fetchedPackageInfo.channels.entrySet()) {
loader.logger.info("---------- Channel: " + chan.getKey() + " ----------");
loader.logger.info("Version: " + Utility.join(", ", chan.getValue()));
loader.logger.info("");
Expand Down

0 comments on commit f716a26

Please sign in to comment.