OsmAnd/DataExtractionOSM/src/net/osmand/ExceptionHandler.java
Victor Shcherb 50249440e2 change net.osmand
git-svn-id: https://osmand.googlecode.com/svn/trunk@455 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
2010-08-16 22:36:24 +00:00

44 lines
961 B
Java

package net.osmand;
import javax.swing.JOptionPane;
import net.osmand.swing.OsmExtractionUI;
import org.apache.commons.logging.Log;
public class ExceptionHandler {
private static final Log log = LogUtil.getLog(ExceptionHandler.class);
public static void handle(Throwable e){
handle("Error occurred", e);
}
public static void handle(String msg, Throwable e){
if(e != null){
log.error(msg, e);
} else {
log.error(msg);
}
if(e != null){
e.printStackTrace();
}
if (OsmExtractionUI.MAIN_APP != null && OsmExtractionUI.MAIN_APP.getFrame() != null) {
String text;
String title;
if (e != null) {
text = e+" ";
title = msg;
} else {
title = "Error occured";
text = msg;
}
JOptionPane.showMessageDialog(OsmExtractionUI.MAIN_APP.getFrame(), text, title, JOptionPane.ERROR_MESSAGE);
}
}
public static void handle(String msg){
handle(msg, null);
}
}