Browse Source

Slf4j a few more bits.

pull/583/head
Chris Smith 9 years ago
parent
commit
2c6a9413e3
2 changed files with 10 additions and 20 deletions
  1. 4
    9
      src/com/dmdirc/Server.java
  2. 6
    11
      src/com/dmdirc/ServerEventHandler.java

+ 4
- 9
src/com/dmdirc/Server.java View File

@@ -24,7 +24,6 @@ package com.dmdirc;
24 24
 
25 25
 import com.dmdirc.commandparser.CommandType;
26 26
 import com.dmdirc.config.profiles.Profile;
27
-import com.dmdirc.events.AppErrorEvent;
28 27
 import com.dmdirc.events.ServerConnectErrorEvent;
29 28
 import com.dmdirc.events.ServerConnectedEvent;
30 29
 import com.dmdirc.events.ServerConnectingEvent;
@@ -39,7 +38,6 @@ import com.dmdirc.interfaces.config.ConfigChangeListener;
39 38
 import com.dmdirc.interfaces.config.ConfigProvider;
40 39
 import com.dmdirc.interfaces.config.ConfigProviderMigrator;
41 40
 import com.dmdirc.interfaces.config.IdentityFactory;
42
-import com.dmdirc.logger.ErrorLevel;
43 41
 import com.dmdirc.parser.common.DefaultStringConverter;
44 42
 import com.dmdirc.parser.common.IgnoreList;
45 43
 import com.dmdirc.parser.common.ParserError;
@@ -89,6 +87,7 @@ import javax.net.ssl.SSLException;
89 87
 import org.slf4j.Logger;
90 88
 import org.slf4j.LoggerFactory;
91 89
 
90
+import static com.dmdirc.util.LogUtils.APP_ERROR;
92 91
 import static com.google.common.base.Preconditions.checkNotNull;
93 92
 
94 93
 /**
@@ -252,9 +251,7 @@ public class Server extends FrameContainer implements Connection {
252 251
                     this.address = new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(),
253 252
                             pd.getDefaultPort(), uri.getPath(), uri.getQuery(), uri.getFragment());
254 253
                 } catch (URISyntaxException ex) {
255
-                    getEventBus().publish(
256
-                            new AppErrorEvent(ErrorLevel.MEDIUM, ex, "Unable to construct URI",
257
-                                    ""));
254
+                    LOG.warn(APP_ERROR, "Unable to construct URI", ex);
258 255
                 }
259 256
             });
260 257
         }
@@ -943,10 +940,8 @@ public class Server extends FrameContainer implements Connection {
943 940
                         || exception instanceof SSLException) {
944 941
                     description = exception.getMessage();
945 942
                 } else {
946
-                    getEventBus().publish(new AppErrorEvent(ErrorLevel.LOW,
947
-                            new IllegalArgumentException(exception),
948
-                            "Unknown socket error: " + exception.getClass().getCanonicalName(),
949
-                            ""));
943
+                    LOG.info(APP_ERROR, "Unknown socket error: {}",
944
+                            exception.getClass().getCanonicalName(), exception);
950 945
                     description = "Unknown error: " + exception.getMessage();
951 946
                 }
952 947
             }

+ 6
- 11
src/com/dmdirc/ServerEventHandler.java View File

@@ -22,7 +22,6 @@
22 22
 
23 23
 package com.dmdirc;
24 24
 
25
-import com.dmdirc.events.AppErrorEvent;
26 25
 import com.dmdirc.events.QuerySelfActionEvent;
27 26
 import com.dmdirc.events.QuerySelfMessageEvent;
28 27
 import com.dmdirc.events.ServerAuthNoticeEvent;
@@ -51,10 +50,8 @@ import com.dmdirc.events.ServerWalldesyncEvent;
51 50
 import com.dmdirc.events.ServerWallopsEvent;
52 51
 import com.dmdirc.events.ServerWallusersEvent;
53 52
 import com.dmdirc.events.StatusBarMessageEvent;
54
-import com.dmdirc.events.UserErrorEvent;
55 53
 import com.dmdirc.events.UserInfoResponseEvent;
56 54
 import com.dmdirc.interfaces.Connection;
57
-import com.dmdirc.logger.ErrorLevel;
58 55
 import com.dmdirc.parser.common.AwayState;
59 56
 import com.dmdirc.parser.events.AuthNoticeEvent;
60 57
 import com.dmdirc.parser.events.AwayStateEvent;
@@ -104,6 +101,9 @@ import org.slf4j.LoggerFactory;
104 101
 
105 102
 import net.engio.mbassy.listener.Handler;
106 103
 
104
+import static com.dmdirc.util.LogUtils.APP_ERROR;
105
+import static com.dmdirc.util.LogUtils.USER_ERROR;
106
+
107 107
 /**
108 108
  * Handles parser events for a Server object.
109 109
  */
@@ -165,8 +165,7 @@ public class ServerEventHandler extends EventHandler {
165 165
     @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
166 166
     @Handler
167 167
     public void onErrorInfo(final ParserErrorEvent event) {
168
-        eventBus.publishAsync(new AppErrorEvent(ErrorLevel.UNKNOWN, event.getThrowable(),
169
-                event.getThrowable().getMessage(), ""));
168
+        LOG.warn(APP_ERROR, "Error in parser", event.getThrowable());
170 169
     }
171 170
 
172 171
     @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
@@ -189,12 +188,8 @@ public class ServerEventHandler extends EventHandler {
189 188
         final Exception ex = event.getErrorInfo().isException() ? event.getErrorInfo().getException()
190 189
                 : new Exception(errorString.toString()); // NOPMD
191 190
 
192
-        final ErrorLevel errorLevel = ErrorLevel.UNKNOWN;
193
-        if (event.getErrorInfo().isUserError()) {
194
-            eventBus.publishAsync(new UserErrorEvent(errorLevel, ex, event.getErrorInfo().getData(), ""));
195
-        } else {
196
-            eventBus.publishAsync(new AppErrorEvent(errorLevel, ex, event.getErrorInfo().getData(), ""));
197
-        }
191
+        LOG.warn(event.getErrorInfo().isUserError() ? USER_ERROR : APP_ERROR,
192
+                event.getErrorInfo().getData(), ex);
198 193
     }
199 194
 
200 195
     @Handler

Loading…
Cancel
Save