天天看点

jsf学习(异常类的封装)

    public static String ProcessWebExceptionMessage(String aCode,

            String myString, Exception E) {

        String yc="";

        String ycxx="";

        if (wlglException.class.isInstance(E)){

            yc="YzSystemException";

            ycxx="myString";

        } else{

            yc=E.toString();

            ycxx=E.getMessage();

        }

        String returnValue = "YzSystem" + aCode +

                             "/n<br>-------------异常描述开始("+myString+")-------------------" +

                             "/n<br>本地描述:" + myString +

                             "/n<br>异常:" + yc +

                             "/n<br>异常消息:" + ycxx

                             ;

        System.err.println(returnValue);

        StringWriter sw = new StringWriter();

        PrintWriter ps = new PrintWriter(sw, true);

        E.printStackTrace(ps);

//                    out.println("<P>" + sw.getBuffer() + "</P>");

        String errorInfo = "/n<br>异常堆栈:" + sw.getBuffer()+

                           "/n<br>---------------异常描述结束("+myString+")-----------------/n";

        returnValue+=errorInfo;

        return returnValue;

    }