You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Elliotte Rusty Harold (Jira)" <ji...@apache.org> on 2021/05/09 10:19:00 UTC

[jira] [Commented] (MNG-7093) Construct exceptions with args to String.format().

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

Elliotte Rusty Harold commented on MNG-7093:
--------------------------------------------

I'm -1 on this one.  This is a nonstandard way to create exceptions that developers aren't familiar with. It's extra methods in the API that doesn't add any new functionality. It's simple enough to use String.format before passing in the exception message.

> Construct exceptions with args to String.format().
> --------------------------------------------------
>
>                 Key: MNG-7093
>                 URL: https://issues.apache.org/jira/browse/MNG-7093
>             Project: Maven
>          Issue Type: New Feature
>          Components: Plugin API
>            Reporter: Gary D. Gregory
>            Priority: Minor
>
> Construct exceptions with args to String.format() to allow for a simpler and richer way to build messages, for example, right now, in the Apache Commons release plugin, I say:
> {code:java}
> throw new MojoExecutionException("Failed to add files to SCM: " + addResult.getProviderMessage()
>                             + " [" + addResult.getCommandOutput() + "]");
> ...
> throw new MojoExecutionException(String.format("Failed to copy '%s' to '%s'", name, scmTargetPath), e);
> {code}
> But it would be nicer to say:
> {code:java}
> throw new MojoExecutionException("Failed to add files to SCM: %s [%s]", addResult.getProviderMessage(), addResult.getCommandOutput());
> ...
> throw new MojoExecutionException(e, "Failed to copy '%s' to '%s'", name, scmTargetPath));
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)