Skip to content

New rule: Do not pass cause.getMessage() if you already passed the cause to a new exception #125

@dgroup

Description

@dgroup

Summary

Key Value
Rule ...
Ruleset io/github/dgroup/arch4u/pmd/....xml
Category Design
Framework ...
Since 0.2.0
Incidents in past at my experience 1
Template true/false

Rule definition

<rule name="..."
      since="0.2.0"
      language="java"
      externalInfoUrl="https://github.com/dgroup/arch4u-pmd/discussions/..."
      message="...: https://github.com/dgroup/arch4u-pmd/discussions/..."
      class="io.github.dgroup.arch4u.pmd....">
    <priority>3</priority>
    <properties>
      <property name="..." delimiter="|" value="...|...|...|..."/>
      <property name="..." value="...|..."/>
    </properties>
</rule>

Why?

The necessary error context might not be passed to the new exception

  throw new MyException(cause, "Couldn't initialize URI. : %s", cause.getMessage());

in this case, its better to do it like

  throw new MyException(cause, "Couldn't initialize URI : %s", uri);

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions