-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gwt: Explicit exception catching and pretty printing.
- Loading branch information
1 parent
9ccb08d
commit a4ee3fc
Showing
21 changed files
with
184 additions
and
109 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
gwt/vmchecker-gui/src/ro/pub/cs/vmchecker/client/ExceptionHandler.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package ro.pub.cs.vmchecker.client; | ||
|
||
import ro.pub.cs.vmchecker.client.event.ErrorDisplayEvent; | ||
|
||
import com.google.gwt.core.client.GWT; | ||
import com.google.gwt.event.shared.HandlerManager; | ||
import ro.pub.cs.vmchecker.client.i18n.VmcheckerConstants; | ||
|
||
public class ExceptionHandler { | ||
|
||
private static ExceptionHandler exceptionHandlerSingleton; | ||
|
||
private HandlerManager eventBus; | ||
private static VmcheckerConstants constants = GWT | ||
.create(VmcheckerConstants.class); | ||
|
||
private ExceptionHandler() { } | ||
|
||
public static ExceptionHandler getInstance() { | ||
if (exceptionHandlerSingleton == null) { | ||
exceptionHandlerSingleton = new ExceptionHandler(); | ||
} | ||
return exceptionHandlerSingleton; | ||
} | ||
|
||
public void setEventBus(HandlerManager eventBus) { | ||
this.eventBus = eventBus; | ||
} | ||
|
||
public void exceptionError(Exception e) { | ||
GWT.log("[exceptionError()]", e); | ||
/* unhandled exception. get stack trace. */ | ||
|
||
if (eventBus == null) return; | ||
|
||
StringBuilder sb = new StringBuilder(); | ||
for (StackTraceElement element : e.getStackTrace()) { | ||
sb.append(element + "<br/>"); | ||
} | ||
|
||
eventBus.fireEvent(new ErrorDisplayEvent(constants.exceptionError() + " " + constants.exceptionErrorText(), | ||
"<b>" + constants.exceptionErrorContent() + "</b>:<br/>" + e.toString() + | ||
"<br/>" + sb.toString() + "<br/>")); | ||
} | ||
} |
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
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
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
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
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
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
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
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
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
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
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
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
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
Oops, something went wrong.