Home > Java > javaTutorial > body text

How to log all exceptions thrown by a method in Java?

PHPz
Release: 2023-04-23 12:19:07
forward
927 people have browsed it

Log all exceptions thrown by each method

This is seriously underused. Most public APIs don't have @throws Java documentation to explain the exceptions thrown.

This is a good example.

...
 *
 * @throws MalformedURLException The formal system identifier of a
 * subordinate catalog cannot be turned into a valid URL.
 * @throws IOException Error reading subordinate catalog file.
 */
public String resolveSystem(String systemId)
  throws MalformedURLException, IOException {
...
Copy after login

This is a bad example of a lack of information about under what circumstances an exception is thrown.

 * @throws Exception exception
 */
public void startServer() throws Exception {
    if (!externalDatabaseHost) {
Copy after login

The above is the detailed content of How to log all exceptions thrown by a method in Java?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template