Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
dgroup opened this issue Apr 11, 2022 · 0 comments
Assignees
Labels

Comments

@dgroup
Copy link
Owner

dgroup commented Apr 11, 2022

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);
@dgroup dgroup self-assigned this Apr 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant