2010-05-14 13:44:35 +02:00
|
|
|
package com.osmand;
|
|
|
|
|
2010-06-02 15:27:50 +02:00
|
|
|
import javax.swing.JOptionPane;
|
|
|
|
|
2010-05-14 13:44:35 +02:00
|
|
|
import org.apache.commons.logging.Log;
|
|
|
|
|
2010-06-02 15:27:50 +02:00
|
|
|
import com.osmand.swing.OsmExtractionUI;
|
|
|
|
|
2010-05-14 13:44:35 +02:00
|
|
|
public class ExceptionHandler {
|
|
|
|
private static final Log log = LogUtil.getLog(ExceptionHandler.class);
|
|
|
|
|
2010-06-02 15:27:50 +02:00
|
|
|
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) {
|
2010-06-14 23:14:36 +02:00
|
|
|
text = e+" ";
|
2010-06-02 15:27:50 +02:00
|
|
|
title = msg;
|
|
|
|
} else {
|
|
|
|
title = "Error occured";
|
|
|
|
text = msg;
|
|
|
|
}
|
|
|
|
JOptionPane.showMessageDialog(OsmExtractionUI.MAIN_APP.getFrame(), text, title, JOptionPane.ERROR_MESSAGE);
|
|
|
|
}
|
2010-05-14 13:44:35 +02:00
|
|
|
}
|
|
|
|
|
2010-06-02 15:27:50 +02:00
|
|
|
public static void handle(String msg){
|
|
|
|
handle(msg, null);
|
2010-05-14 13:44:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|