Skip to content

Either log or rethrow this exception #3

Description

@fukit0

printStackTrace yerine hatayı daha anlaşılır şekilde loglamak gerektiğini söylüyolar. Sadece printStackTrace de değil tabiki.

e.printStackTrace() is generally discouraged because it just prints out the stack trace to standard error. Because of this you can't really control where this output goes.

The better thing to do is to use a logging framework (logback, slf4j, java.util.logging, log4j, etc) because then you can control where the errors are logged to and what the log retention policy is.

And generally you'll want to catch the exception and if it's unexpected behavior, log it and either throw a new exception (probably specific to your application) or do whatever you have to do to continue operating gracefully.

https://sonar43.spring.io/rules/show/squid:S1166?layout=false
-- SonarQube

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions