Skip to content

Commit

Permalink
#172 log client exceptions to server
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurensRietveld committed Oct 5, 2013
1 parent cf81c9b commit 53093e3
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/main/java/com/data2semantics/yasgui/client/ViewElements.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,14 @@
import com.data2semantics.yasgui.client.tab.optionbar.LinkCreator;
import com.data2semantics.yasgui.client.tab.optionbar.endpoints.EndpointInput;
import com.data2semantics.yasgui.shared.exceptions.ElementIdException;
import com.data2semantics.yasgui.shared.exceptions.FetchException;
import com.google.gwt.dom.client.Style.Cursor;
import com.google.gwt.dom.client.Style.Position;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.logical.shared.ResizeEvent;
import com.google.gwt.event.logical.shared.ResizeHandler;
import com.google.gwt.http.client.URL;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.types.VerticalAlignment;
Expand Down Expand Up @@ -283,6 +285,20 @@ public void onError(Throwable e) {
} else {
errorMsg = e.getMessage();
}
if (view.getConnHelper().isOnline()) {
//Log exception to server
new GwtCallbackWrapper<Void>(view) {
public void onCall(AsyncCallback<Void> callback) {
view.getRemoteService().logException(new FetchException("blaat"), callback);
}

protected void onFailure(Throwable throwable) {
}

protected void onSuccess(Void prefixes) {
}
}.call();
}

onError(errorMsg);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@ public interface YasguiService extends RemoteService {
void deleteBookmarks(int[] bookmarkIds) throws IllegalArgumentException, FetchException;
Bookmark[] getBookmarks() throws IllegalArgumentException, FetchException;
boolean isOnline() throws IllegalArgumentException;
void logException(Throwable e);
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import java.io.IOException;
import java.sql.SQLException;
import java.text.ParseException;
import java.util.logging.FileHandler;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.Logger;

Expand Down Expand Up @@ -59,8 +61,11 @@
*/
@SuppressWarnings("serial")
public class YasguiServiceImpl extends RemoteServiceServlet implements YasguiService {

public static String CACHE_DIR = "/cache";
private final static Logger LOGGER = Logger.getLogger(YasguiServiceImpl.class.getName());
private static Logger LOGGER = Logger.getLogger(YasguiServiceImpl.class.getName());



public String fetchPrefixes(boolean forceUpdate) throws IllegalArgumentException, FetchException {
String prefixes = "";
Expand Down Expand Up @@ -244,4 +249,20 @@ public String fetchProperties(String endpoint, boolean forceUpdate) throws Illeg
public boolean isOnline() throws IllegalArgumentException {
return true;
}

@Override
public void logException(Throwable t) {
if (System.getProperty("catalina.base") != null) {
try {
Handler handler = new FileHandler(System.getProperty("catalina.base") + "/logs/yasgui.err");
LOGGER.addHandler(handler);
LOGGER.log(Level.SEVERE, t.getMessage(), t);
handler.close();
} catch (Exception e) {
e.printStackTrace();
}
} else {
LOGGER.log(Level.SEVERE, t.getMessage(), t);
}
}
}

0 comments on commit 53093e3

Please sign in to comment.