You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Many exceptions are only for syntactically invalid config values, but not all of them. Plugin code handles these exceptions in long catch blocks. Sometimes we use HelpfulSuggestions for error messages, but sometimes not. This long blocks are being copied over three tasks (build, dockerBuild, buildTar). I honestly don't know how we can best handle this.
details (click to unfold)
} catch (InvalidContainerizingModeExceptionex) {
thrownewMojoExecutionException(
"invalid value for <containerizingMode>: " + ex.getInvalidContainerizingMode(), ex);
} catch (InvalidWorkingDirectoryExceptionex) {
thrownewMojoExecutionException(
"<container><workingDirectory> is not an absolute Unix-style path: "
+ ex.getInvalidPathValue(),
ex);
} catch (InvalidContainerVolumeExceptionex) {
thrownewMojoExecutionException(
"<container><volumes> is not an absolute Unix-style path: " + ex.getInvalidVolume(), ex);
} catch (InvalidFilesModificationTimeExceptionex) {
thrownewMojoExecutionException(
"<container><filesModificationTime> should be an ISO 8601 date-time (see "
+ "DateTimeFormatter.ISO_DATE_TIME) or special keyword \"EPOCH_PLUS_SECOND\": "
+ ex.getInvalidFilesModificationTime(),
ex);
} catch (IncompatibleBaseImageJavaVersionExceptionex) {
thrownewMojoExecutionException(
HelpfulSuggestions.forIncompatibleBaseImageJavaVesionForMaven(
ex.getBaseImageMajorJavaVersion(), ex.getProjectMajorJavaVersion()),
ex);
} catch (InvalidImageReferenceExceptionex) {
thrownewMojoExecutionException(
HelpfulSuggestions.forInvalidImageReference(ex.getInvalidReference()), ex);
} catch (IOException | CacheDirectoryCreationException | MainClassInferenceExceptionex) {
thrownewMojoExecutionException(ex.getMessage(), ex);
} catch (BuildStepsExecutionExceptionex) {
thrownewMojoExecutionException(ex.getMessage(), ex.getCause());
}
}
The text was updated successfully, but these errors were encountered:
I've been thinking about this a bit, and I have a couple ideas:
Just do straightforward code reduction. catch(Exception ex) and pass ex into a method in TaskCommon/MojoCommon that checks the type and rethrows with the message we want, and if it's not a type we know, throw ex. This doesn't help with PluginConfigurationProcessor throwing so many exceptions, but it's an easy way of reducing a decent amount of duplicate code.
Do something like remove all these custom exception classes and put all the failures under a JibPluginException that just takes a message. Maybe we can move all the messages we'd pass to it into HelpfulSuggestions to unify things a bit better. But this might either increase the number of parameters we need to pass into HelpfulSuggestions (since maven and gradle have different terminology, parameter names, etc.), or require us to make HelpfulSuggestions an interface with a maven and gradle implementation.
PluginConfigurationProcessor
throws many exceptions.Many exceptions are only for syntactically invalid config values, but not all of them. Plugin code handles these exceptions in long catch blocks. Sometimes we use
HelpfulSuggestions
for error messages, but sometimes not. This long blocks are being copied over three tasks (build, dockerBuild, buildTar). I honestly don't know how we can best handle this.details (click to unfold)
The text was updated successfully, but these errors were encountered: