Skip to content

Commit

Permalink
Fix code smell and avoid cycle in exception use
Browse files Browse the repository at this point in the history
  • Loading branch information
baloo42 committed Oct 6, 2024
1 parent feeb169 commit 9749f4c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -314,24 +314,4 @@ static CommandLine createCommandLine(CRDGeneratorCLI crdGeneratorCLI) {
.setExecutionExceptionHandler(new CRDGeneratorExecutionExceptionHandler(crdGeneratorCLI));
}

/**
* Exception to indicate that no custom resource classes
* have been retained after scanning and filtering.
*/
static class CustomResourceClassNotFoundException extends CRDGeneratorCliException {
CustomResourceClassNotFoundException() {
super("No Custom Resource class retained after filtering");
}
}

private static class CRDGeneratorCliException extends RuntimeException {
CRDGeneratorCliException(String message) {
super(message);
}

CRDGeneratorCliException(String message, Throwable cause) {
super(message, cause);
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.fabric8.crd.generator.cli;

class CRDGeneratorCliException extends RuntimeException {
CRDGeneratorCliException(String message) {
super(message);
}

CRDGeneratorCliException(String message, Throwable cause) {
super(message, cause);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public int handleExecutionException(
return CRDGeneratorExitCode.CR_CLASS_LOADING;
}

if (ex instanceof CRDGeneratorCLI.CustomResourceClassNotFoundException) {
if (ex instanceof CustomResourceClassNotFoundException) {
commandLine.getErr().println();
commandLine.getErr().println("Check JAR files and directories considered to be scanned " +
"as well as your filters. At least one Custom Resource class " +
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.fabric8.crd.generator.cli;

/**
* Exception to indicate that no custom resource classes have been retained after scanning and
* filtering.
*/
class CustomResourceClassNotFoundException extends CRDGeneratorCliException {
CustomResourceClassNotFoundException() {
super("No Custom Resource class retained after filtering");
}
}

0 comments on commit 9749f4c

Please sign in to comment.