blob: 3589ef42b2bd1518c6b5f7c9761851f9d0f8bc44 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
package com.vaadin.tests.application;
import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.Button;
import com.vaadin.ui.Notification;
import com.vaadin.ui.UI;
public class TerminalErrorNotification extends TestBase {
@Override
protected void setup() {
Button button = new Button("Throw exception", event -> {
throw new RuntimeException("You asked for it");
});
addComponent(button);
}
@Override
public void error(com.vaadin.server.ErrorEvent event) {
event.getThrowable().printStackTrace();
UI mainWindow = getMainWindow();
if (mainWindow != null) {
Throwable throwable = event.getThrowable();
// Find the root cause
while (throwable.getCause() != null) {
throwable = throwable.getCause();
}
Notification.show("Got an exception: " + throwable.getMessage(),
Notification.TYPE_ERROR_MESSAGE);
} else {
System.out.println("No main window found");
}
}
@Override
protected String getDescription() {
return "Showing a notification in the terminalError method should make the notification appear in the browser.";
}
@Override
protected Integer getTicketNumber() {
return Integer.valueOf(8778);
}
}
|