| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- package xin.glue.user.common;
- import java.io.FileNotFoundException;
- import java.io.IOException;
- import jxl.write.WriteException;
- import com.posdata.glue.PosException;
- import com.posdata.glue.biz.activity.PosActivity;
- import com.posdata.glue.biz.constants.PosBizControlConstants;
- import com.posdata.glue.context.PosContext;
- import com.posdata.glue.dao.PosDaoException;
- /**
- *
- * @Description 错误管理
- * @author 梅贵平{meiguiping}
- * @date 2008-10-29 下午05:49:51
- * @JDK Version jdk1.4.2
- */
- public class PosErrorHandler extends PosActivity
- {
- public String runActivity(PosContext context)
- {
- Throwable th = context.getException();
- /*PosMessage errorMessage = context.getMessage();
- String message = "";
- if(errorMessage != null)
- {
- message = (String)errorMessage.get("errorMsg");
- }
-
- if("".equals(message))
- {
- message = "发生未知异常,请咨询管理者";
- }*/
- String msg = (String)context.get("errorMsg");
- String message = "发生未知异常,请咨询管理者";
-
- if(msg != null && !"".equals(msg))
- {
- message = msg;
- }
- if (th != null)
- {
- if (th instanceof PosDaoException)
- {
- message = "DB处理中发生了错误,请咨询管理者";
- }
- else if (th instanceof PosException)
- {
- message = "系统发生了错误,请咨询管理者";
- }
- else if (th instanceof FileNotFoundException)
- {
- message = "创建文件时发生了错误,请咨询管理者。\r\n一般原因是:\r\n(1)文件名命名不规范\r\n(2)文件路径不正确\r\n(3)文件正在被使用";
- message = message.replaceAll ( "\r", "" );
- message = message.replaceAll ( "\n", "\\"+System.getProperty("line.separator"));
- }
- else if (th instanceof IOException)
- {
- message = "读写文件时发生了错误,请咨询管理者";
- }
- else if (th instanceof WriteException)
- {
- message = "导出EXCEL时发生了错误,请咨询管理者";
- }
- }
- //new Exception("ddd");
- context.setException(new PosException(message));
-
- this.rollbackTransaction("tx1");
- return PosBizControlConstants.SUCCESS;
- }
- }
|