Skip to content

Commit

Permalink
Add log output in case of RuntimeException #271
Browse files Browse the repository at this point in the history
  • Loading branch information
waynebeaton committed Dec 7, 2023
1 parent 4ca2a96 commit 1f3fcd9
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions core/src/main/java/org/eclipse/dash/licenses/cli/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@
import org.eclipse.dash.licenses.review.CreateReviewRequestCollector;
import org.eclipse.dash.licenses.review.GitLabSupport;
import org.eclipse.dash.licenses.validation.EclipseProjectIdValidator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.inject.Guice;
import com.google.inject.Injector;

/**
* This class provides a CLI entrypoint to determine licenses for content. The
* This class provides a CLI entry point to determine licenses for content. The
* tool can be invoked in a few different ways, e.g.
*
* <pre>
Expand All @@ -59,8 +61,14 @@ public class Main {
*/
final static Integer INTERNAL_ERROR = 127;

final Logger logger = LoggerFactory.getLogger(Main.class);

public static void main(String[] args) {
CommandLineSettings settings = CommandLineSettings.getSettings(args);
new Main().doit(settings);
}

void doit(CommandLineSettings settings) {
if (!settings.isValid()) {
CommandLineSettings.printUsage(System.out);
System.exit(INTERNAL_ERROR);
Expand Down Expand Up @@ -127,6 +135,7 @@ public static void main(String[] args) {
collectors.forEach(collector -> collector.accept(licenseData));
});
} catch (RuntimeException e) {
logger.debug(e.getMessage(), e);
System.exit(INTERNAL_ERROR);
}
}
Expand All @@ -137,14 +146,14 @@ public static void main(String[] args) {
System.exit(Math.min(primaryCollector.getStatus(), INTERNAL_ERROR - 1));
}

private static OutputStream getWriter(String path) throws FileNotFoundException {
private OutputStream getWriter(String path) throws FileNotFoundException {
if ("-".equals(path))
return System.out;
return new FileOutputStream(new File(path));
}

@SuppressWarnings("resource")
private static IDependencyListReader getReader(String name) throws FileNotFoundException {
private IDependencyListReader getReader(String name) throws FileNotFoundException {
if ("-".equals(name)) {
return new FlatFileReader(new InputStreamReader(System.in));
} else {
Expand Down

0 comments on commit 1f3fcd9

Please sign in to comment.