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

Why shouldn't exceptions be ignored in Java development?

PHPz
PHPzforward
2023-04-22 19:43:151128browse

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;
}

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!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete