16
16
17
17
import java .awt .event .ActionEvent ;
18
18
import java .awt .event .ActionListener ;
19
+ import java .io .FileNotFoundException ;
20
+ import java .io .IOException ;
21
+ import java .net .UnknownHostException ;
19
22
import java .util .logging .Level ;
20
23
import java .util .logging .Logger ;
21
24
@@ -26,8 +29,9 @@ public class LoginManager {
26
29
private boolean ready ;
27
30
private Logger log = Logger .getLogger (LoginManager .class .getName ());
28
31
private AuthenticationFailedException authenticationException ;
32
+ private IOException connectionException ;
29
33
30
- public synchronized void login () throws InterruptedException , AuthenticationFailedException {
34
+ public synchronized void login () throws InterruptedException , AuthenticationFailedException , IOException {
31
35
if (LoginDialog .isWindowVisible () || OrganizationListWindow .isWindowVisible () || CourseListWindow .isWindowVisible ()) {
32
36
return ;
33
37
}
@@ -49,6 +53,14 @@ public void actionPerformed(ActionEvent e) {
49
53
try {
50
54
TmcCore .get ().authenticate (ProgressObserver .NULL_OBSERVER , TmcSettingsHolder .get ().getPassword ().get ()).call ();
51
55
} catch (Exception ex ) {
56
+ if (ex instanceof IOException ) {
57
+ connectionException = (IOException )ex ;
58
+ if (ex instanceof UnknownHostException ) {
59
+ ConvenientDialogDisplayer .getDefault ().displayError ("Couldn't connect to the server. Please check your internet connection." );
60
+ } else if (ex instanceof FileNotFoundException ) {
61
+ ConvenientDialogDisplayer .getDefault ().displayError ("Server address is incorrect." );
62
+ }
63
+ }
52
64
if (ex instanceof AuthenticationFailedException ) {
53
65
authenticationException = (AuthenticationFailedException ) ex ;
54
66
ConvenientDialogDisplayer .getDefault ().displayError ("Username or password is incorrect." , ex );
@@ -66,7 +78,10 @@ public void actionPerformed(ActionEvent e) {
66
78
if (authenticationException != null ) {
67
79
throw authenticationException ;
68
80
}
69
- showOrganizations ();
81
+ if (connectionException != null ) {
82
+ throw connectionException ;
83
+ }
84
+ showOrganizations ();
70
85
}
71
86
72
87
public void setReady (boolean value ) {
0 commit comments