[ 
https://issues.apache.org/jira/browse/MNG-8196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17872632#comment-17872632
 ] 

ASF GitHub Bot commented on MNG-8196:
-------------------------------------

gnodet commented on code in PR #1628:
URL: https://github.com/apache/maven/pull/1628#discussion_r1712795232


##########
maven-core/src/main/java/org/apache/maven/plugin/DefaultBuildPluginManager.java:
##########
@@ -143,7 +143,7 @@ public void executeMojo(MavenSession session, MojoExecution 
mojoExecution)
                 mojoExecutionListener.beforeMojoExecution(mojoExecutionEvent);
                 mojo.execute();
                 
mojoExecutionListener.afterMojoExecutionSuccess(mojoExecutionEvent);
-            } catch (ClassCastException e) {
+            } catch (ClassCastException | MojoException e) {

Review Comment:
   `MojoException` is actually a `RuntimeException`, so the outer catch block 
needs to be enhanced to rethrow directly instead of calling 
`mojoExecutionListener.afterExecutionFailure`.  Just to keep the old behaviour.



##########
maven-core/src/main/java/org/apache/maven/plugin/DefaultBuildPluginManager.java:
##########
@@ -143,7 +143,7 @@ public void executeMojo(MavenSession session, MojoExecution 
mojoExecution)
                 mojoExecutionListener.beforeMojoExecution(mojoExecutionEvent);
                 mojo.execute();
                 
mojoExecutionListener.afterMojoExecutionSuccess(mojoExecutionEvent);
-            } catch (ClassCastException e) {
+            } catch (ClassCastException | MojoException e) {

Review Comment:
   Also, I would extend to any `MavenException`, since those are rather 
expected conditions.





> Make exception messages match Maven 3 again
> -------------------------------------------
>
>                 Key: MNG-8196
>                 URL: https://issues.apache.org/jira/browse/MNG-8196
>             Project: Maven
>          Issue Type: Improvement
>          Components: Core
>            Reporter: Tamas Cservenak
>            Priority: Major
>             Fix For: 4.0.0, 4.0.0-beta-4
>
>
> The boxing of `MojoException` into a `MojoExecutionException` brought two 
> issues:
> 1. It added another layer to the stacktrace, making it a bit less readable 
> for users and breaking test expectations for Maven extension authors (the 
> latter was my main motivation for this change)
> 2. It lost the `longMessage`, which meant that this message was no longer 
> shown at the end of the build.
> This change fixes both problems by passing through the original 
> `MojoException` and treating this new exception type directly in 
> `DefaultExceptionHandler` and `MojoExecutor`



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to