You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Gary D. Gregory (Jira)" <ji...@apache.org> on 2021/02/06 20:01:00 UTC

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

Gary D. Gregory created MNG-7093:
------------------------------------

             Summary: 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


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)