Home > Java > javaTutorial > Why shouldn't exceptions be ignored in Java development?

Why shouldn't exceptions be ignored in Java development?

PHPz
Release: 2023-04-22 19:43:15
forward
1150 people have browsed it

Don't ignore exceptions

public static Bundle decodeUrl(String s) {
    Bundle params = new Bundle();
    if (s != null) {
        String array[] = s.split("&");
        for (String parameter : array) {
            String v[] = parameter.split("=");
            try {
                params.putString(URLDecoder.decode(v[0], "UTF-8"), URLDecoder.decode(v[1], "UTF-8"));
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
        }
    }
    return params;
}
Copy after login

Printing stack traces should almost always be avoided in production code. This is just as bad as ignoring the exception. This will write to the standard error stream, which is not where the logging framework is used.

The above is the detailed content of Why shouldn't exceptions be ignored in Java development?. 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