Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve xmomcompiler error message #663

Merged
merged 2 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions server/src/com/gip/xyna/xmcp/xfcli/scriptentry/XMOMCompiler.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* Copyright 2023 Xyna GmbH, Germany
* Copyright 2024 Xyna GmbH, Germany
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -27,6 +27,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -449,13 +450,33 @@ private Set<RuntimeContext> findRelevantRevisions(RuntimeContext toBuild, FileSy
relevant.add(toBuild);
try {
Long revision = source.getRevision(toBuild);
if(revision == null) {
throw new RuntimeException("Could not find " + toBuild + ". Available runtimecontexts:\n" + createRTCListString(source));
}
Stream<Long> revisions = source.getDependenciesRecursivly(revision).stream();
relevant.addAll(revisions.map(r -> mapToRuntimeContext(r, source)).collect(Collectors.toSet()));
} catch (XNWH_OBJECT_NOT_FOUND_FOR_PRIMARY_KEY e) {
throw new RuntimeException(e);
} catch (Exception e) {
throw new RuntimeException(e.getMessage()+" Available runtimecontexts:\n" + createRTCListString(source), e);
}
return relevant;
}

private String createRTCListString(FileSystemXMLSource source) {
StringBuilder sb = new StringBuilder();
List<Long> revisions = new ArrayList<>(source.getRevisions());
Collections.sort(revisions);
try {
for(Long revision : revisions) {
RuntimeContext rtc = source.getRuntimeContext(revision);
sb.append(rtc).append(": ");
sb.append(source.getXMOMPath(rtc).getParent());
sb.append("\n");
}
} catch(Exception e) {
sb.append("ERROR: ").append(e.getMessage());
}
return sb.toString();
}


private RuntimeContext mapToRuntimeContext(Long revision, FileSystemXMLSource source) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void analyzeException(MDMParallelDeploymentException e) {
private void analyzeDeployException(Throwable t, GenerationBase gb) {

//defined no or multiple unique identifiers
if (t instanceof RuntimeException && t.getMessage().endsWith("unique identifier.")) {
if (t instanceof RuntimeException && t.getMessage() != null && t.getMessage().endsWith("unique identifier.")) {
System.out.println("ERROR: " + t.getMessage() + " - check \"xprc.xfractwfe.generation.storable.xmom.interfaces\"");
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6914,6 +6914,10 @@ public FileSystemXMLSource(Map<RuntimeContext, Set<RuntimeContext>> rtcDependenc
revisions.put(rtx, revision++);
}
}

public Collection<Long> getRevisions() {
return revisions.values();
}

public Set<Long> getDependenciesRecursivly(Long revision) {
Set<Long> dependencies = new HashSet<>();
Expand All @@ -6929,6 +6933,9 @@ private void getDependenciesRecursivlyInternally(Long revision, Set<Long> depene
Set<RuntimeContext> deps = rtcDependencies.get(rtc);
for (RuntimeContext dep : deps) {
Long depRev = revisions.get(dep);
if(depRev == null) {
throw new RuntimeException("Missing dependent RTC: " + dep + ".");
}
if (depenedencies.add(depRev)) {
getDependenciesRecursivlyInternally(depRev, depenedencies);
}
Expand Down
Loading