Skip to content

Commit

Permalink
updated dependency error will throw
Browse files Browse the repository at this point in the history
  • Loading branch information
supertick committed Sep 20, 2023
1 parent 2e567a2 commit 167498f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 21 deletions.
18 changes: 10 additions & 8 deletions src/main/java/org/myrobotlab/framework/repo/IvyWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,9 @@ public void installDependency(String location, ServiceDependency library) {
}

@Override
synchronized public void install(String location, String[] serviceTypes) {
synchronized public void install(String location, String[] serviceTypes) throws IOException {

try {
// try {

Set<ServiceDependency> targetLibraries = getUnfulfilledDependencies(serviceTypes);

Expand Down Expand Up @@ -508,9 +508,11 @@ synchronized public void install(String location, String[] serviceTypes) {
}

if (report == null) {
log.error("problems resolving dependencies");
String errorDetail = String.format("there was problems resolving dependencies %s", (Object[]) serviceTypes);
log.error(errorDetail);
publishStatus(Status.newInstance(Repo.class.getSimpleName(), StatusLevel.ERROR, Repo.INSTALL_FINISHED,
String.format("there was problems resolving dependencies %s", (Object[]) serviceTypes)));
errorDetail));
throw new RuntimeException(errorDetail);
} else {

ArtifactDownloadReport[] artifacts = report.getAllArtifactsReports();
Expand Down Expand Up @@ -538,10 +540,10 @@ synchronized public void install(String location, String[] serviceTypes) {

publishStatus(Status.newInstance(Repo.class.getSimpleName(), StatusLevel.INFO, Repo.INSTALL_FINISHED, String.format("finished install of %s", (Object[]) serviceTypes)));
}
} catch (Exception e) {
error(e.getMessage());
log.error(e.getMessage(), e);
}
// } catch (Exception e) {
// error(e.getMessage());
// log.error(e.getMessage(), e);
// }

}

Expand Down
16 changes: 8 additions & 8 deletions src/main/java/org/myrobotlab/framework/repo/Repo.java
Original file line number Diff line number Diff line change
Expand Up @@ -360,19 +360,19 @@ static public void info(String format, Object... args) {
publishStatus(Status.info(format, args));
}

synchronized public void install() {
synchronized public void install() throws Exception {
// if a runtime exits we'll broadcast we are starting to install
ServiceData sd = ServiceData.getLocalInstance();
info("starting installation of %s services", sd.getServiceTypeNames().length);
install(sd.getServiceTypeNames());
info("finished installing %d services", sd.getServiceTypeNames().length);
}

synchronized public void install(String serviceType) {
synchronized public void install(String serviceType) throws Exception {
install(getInstallDir(), serviceType);
}

synchronized public void install(String location, String serviceType) {
synchronized public void install(String location, String serviceType) throws Exception {

String[] types = null;
if (serviceType == null) {
Expand Down Expand Up @@ -403,18 +403,18 @@ synchronized public void installDependency(String libraries, String[] installDep

abstract public void installDependency(String location, ServiceDependency serviceTypes);

abstract public void install(String location, String[] serviceTypes);
abstract public void install(String location, String[] serviceTypes) throws Exception;

synchronized public void install(String[] serviceTypes) {
synchronized public void install(String[] serviceTypes) throws Exception {
install(getInstallDir(), serviceTypes);
}

public void installEach() {
public void installEach() throws Exception {
String workDir = String.format(String.format("libraries.ivy.services.%d", System.currentTimeMillis()));
installEachTo(workDir);
}

public void installEachTo(String location) {
public void installEachTo(String location) throws Exception {
// if a runtime exits we'll broadcast we are starting to install
ServiceData sd = ServiceData.getLocalInstance();
String[] serviceNames = sd.getServiceTypeNames();
Expand All @@ -423,7 +423,7 @@ public void installEachTo(String location) {
info("finished installing %d services", sd.getServiceTypeNames().length);
}

public void installTo(String location) {
public void installTo(String location) throws Exception {
// if a runtime exits we'll broadcast we are starting to install
ServiceData sd = ServiceData.getLocalInstance();
info("starting installation of %s services", sd.getServiceTypeNames().length);
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/myrobotlab/service/Runtime.java
Original file line number Diff line number Diff line change
Expand Up @@ -1536,7 +1536,8 @@ public void run() {
r.getRepo().install(serviceType);
}
} catch (Exception e) {
r.error(e);
r.error("dependencies failed - install error", e);
throw new RuntimeException(String.format("dependencies failed - install error %s", e.getMessage()));
}
}
};
Expand Down
6 changes: 2 additions & 4 deletions src/test/java/org/myrobotlab/framework/repo/RepoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import static org.junit.Assert.assertTrue;

import java.io.File;
import java.io.IOException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Set;

Expand Down Expand Up @@ -50,7 +48,7 @@ public void setUp() throws Exception {
}

@Test
public void testAddStatusListener() throws ParseException, IOException {
public void testAddStatusListener() throws Exception {
Repo repo = Repo.getInstance();
repo.addStatusPublisher(this);
repo.install("Arduino");
Expand Down Expand Up @@ -81,7 +79,7 @@ public void testGetUnfulfilledDependencies() {
}

@Test
public void testIsInstalled() throws ParseException, IOException {
public void testIsInstalled() throws Exception {
Repo repo = Repo.getInstance();
repo.clear();
repo.install("Arduino");
Expand Down

0 comments on commit 167498f

Please sign in to comment.