⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 exceptionhandler.java

📁 《j2ee开发全程实录》随书源码
💻 JAVA
字号:
package com.cownew.PIS.ui.base;

import org.apache.log4j.Logger;
import org.hibernate.ObjectNotFoundException;
import org.springframework.remoting.RemoteAccessException;

import com.cownew.PIS.framework.common.exception.PISException;
import com.cownew.PIS.ui.ctrl.dialog.ExceptionDialog;
import com.cownew.ctk.common.ExceptionUtils;
import com.cownew.ctk.ui.swing.MsgBox;
import com.cownew.ctk.ui.swing.SwingUtils;

public class ExceptionHandler
{
	private static Logger logger = Logger.getLogger(ExceptionHandler.class);

	public static void handle(Throwable t)
	{
		Throwable realCause = ExceptionUtils.getRealThrowable(t);
		logger.error(realCause.getMessage(), realCause);
		if (realCause instanceof PISException)
		{
			MsgBox.showError(SwingUtils.getActiveWindow(), realCause
					.getMessage());
		} else if (realCause instanceof ObjectNotFoundException)
		{
			ExceptionDialog.showException(realCause, "该记录已不存在!");
		} else if (realCause instanceof RemoteAccessException)
		{
			ExceptionDialog.showException(realCause,
					"无法连接远程服务器,可能远程服务器已经关闭,或者您长时间未进行操作而超时,请联系系统管理员或者尝试重新登录!");
		} else
		{
			ExceptionDialog.showException(realCause);
		}

	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -