Skip to content

Instantly share code, notes, and snippets.

@jnehlmeier
Created December 8, 2014 14:29
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jnehlmeier/cddbc476fd330b1d4999 to your computer and use it in GitHub Desktop.
Save jnehlmeier/cddbc476fd330b1d4999 to your computer and use it in GitHub Desktop.
GWT: Clickable StackTrace in SDM
package de.carecloud.app.client.base.logging;
import com.google.gwt.core.client.GWT;
import com.google.web.bindery.event.shared.UmbrellaException;
public class SuperDevModeUncaughtExceptionHandler implements GWT.UncaughtExceptionHandler {
@Override
public void onUncaughtException(final Throwable t) {
logException(t, false);
}
private void logException(Throwable t, boolean isCause) {
String msg = t.toString();
if(isCause) {
msg = "caused by: " + msg;
}
groupStart(msg);
log(t);
if(t instanceof UmbrellaException) {
UmbrellaException umbrella = (UmbrellaException) t;
for(Throwable cause : umbrella.getCauses()) {
logException(cause, true);
}
} else if (t.getCause() != null) {
logException(t.getCause(), true);
}
groupEnd();
}
private native void groupStart(String msg) /*-{
var groupStart = console.groupCollapsed || console.group || console.error || console.log;
groupStart.call(console, msg);
}-*/;
private native void groupEnd() /*-{
var groupEnd = console.groupEnd || function(){};
groupEnd.call(console);
}-*/;
private native void log(Throwable t) /*-{
var logError = console.error || console.log;
var backingError = t.__gwt$backingJsError;
logError.call(console, backingError && backingError.stack);
}-*/;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment