Created
December 8, 2014 14:29
-
-
Save jnehlmeier/cddbc476fd330b1d4999 to your computer and use it in GitHub Desktop.
GWT: Clickable StackTrace in SDM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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