Comments (13)
That sounds like a great idea.
from gwtp.
I am already on that :)
from gwtp.
Uh, yeah! LOL That was so obvious that I didn't think about it!
from gwtp.
kuhnroyal, cool!
Some way to set an UncaughtExceptionHandler would be really great. I'll use this in the development enviroment to display exceptions:
public class ApplicationDevEntryPoint extends ApplicationEntryPoint {
private static final Logger LOG = Logger.getLogger(ApplicationDevEntryPoint.class.getName());
@Override
public void onModuleLoad() {
GWT.setUncaughtExceptionHandler(new UncaughtExceptionHandler() {
@Override
public void onUncaughtException(final Throwable e) {
LOG.severe(getStacktrace(e));
GWT.log("UncaughtException!", e);
showExceptionPopup(e);
}
});
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
ApplicationDevEntryPoint.super.onModuleLoad();
}
});
}
/**
* @return A quote which should scare the developer.
*/
private String getQuote() {
String quote = "";
quote += "[The crew waits quietly as a Reaver ship passes.] \n";
quote += "Simon: What happens if they board us? \n";
quote += "Zoe: If they take the ship, they'll rape us to death, eat our flesh, and sew our skins into their clothing. \n";
quote += " And if we're very, very lucky they'll do it in that order. \n\n";
return quote;
}
/**
* @return The stacktrace to the given exception.
*/
private String getStacktrace(final Throwable throwable) {
String stacktrace = "";
Throwable cur = throwable;
while (cur != null) {
StackTraceElement[] stackTraceElements = cur.getStackTrace();
stacktrace += cur.toString() + "\n";
for (int i = 0; i < stackTraceElements.length; i++) {
stacktrace += " at " + stackTraceElements[i] + "\n";
}
cur = cur.getCause();
if (cur != null) {
stacktrace += "Caused by: ";
}
}
return stacktrace;
}
/**
* Shows the given exception to the user.
*/
private void showExceptionPopup(final Throwable e) {
String output = getQuote() + getStacktrace(e);
DialogBox dialogBox = new DialogBox(true, false);
DOM.setStyleAttribute(dialogBox.getElement(), "backgroundColor", "#ABCDEF");
dialogBox.setHTML("<pre style='font-family: monospace; font-size: 0.8em; margin: 0; padding: 10px;'>"
+ output + "</pre>");
dialogBox.center();
}
}
from gwtp.
@jbarop I like this idea, but it has disadvantages too if your not aware its being used. Maybe this could be separate issue. Could you move this idea of using a handler to catch exceptions into a new issue? :)
from gwtp.
Couldn't this be done inside an eagerSingleton class? I'm usually installing classes as eagerSingleton for that kind of thing. (Like calling all the ensure injected on my style classes)
from gwtp.
branflake2267, agreed (moved to #103 )
christiangoudreau, I think this will not work as expected because only the next JS event cycle will use the new handler. The excpetions thrown during initialization of the app will be catched by the default handler.
the basic workflow is to set the handler and boot the app in a derefered command (which will happen in a new event cycle).
from gwtp.
Yea I have a similar setup, I'll see what I can come up with.
from gwtp.
Implemented in samples ArcBees/GWTP-Samples#16
EntryPoints can not be generated since there is no call to GWT.create() but MvpWithEntryPoint.gwt.xml now uses the default ClientEntryPoint thus removing the need to add one to your App.
from gwtp.
Would you say this is ready to close?
from gwtp.
Well yes, once #106 is pulled :)
from gwtp.
Nevermind, yes this can be closed!
from gwtp.
Nice work everyone!!!
from gwtp.
Related Issues (20)
- JAX-RS interfaces without RestAction wrappers HOT 1
- ServiceException handling in AbstractDispatchServiceImpl
- links in documentation lead to 404
- Compile failure path for type 'com.gwtplatform.mvp.client.GeneratedMvpEntryPoint' HOT 2
- NestedSlots for presenters.. HOT 5
- Bind constants in superdev mode - cache problem?
- Is GWTP Still Maintained? HOT 11
- Testing a presenter with a DispatchAsync dependency
- GeneratedGwtpModule HOT 3
- @GenEvent tag doesn't manage generic event
- memory leak in PopupViewImpl HOT 1
- Upgrade slot tool when migrating from GWTP 1.4 to 1.6
- Multiple entry points connected to different addresses or URL's
- Calling RestDispatchAsyncModule.Builder.core().responseDeserializer() has no effect on the binding HOT 2
- Issue with PlaceManager in abstract Presenter HOT 1
- RestDispatch: Missing servlet response message on error HOT 1
- Gatekeeper with custom reveal method
- Is there any sample to using ltgt maven plugin? HOT 1
- Upgrade com.google.gwt : 2.8.0 -> 2.9.0 HOT 6
- http://dev.arcbees.com/ throws 500 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gwtp.