mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-17 11:18:55 -04:00
Discord: Don't log IOExceptions to error logs, and also better log errors with IRC
This commit is contained in:
parent
5cc8c82936
commit
8960dcd66f
@ -116,7 +116,7 @@ namespace MCGalaxy.Modules.Relay.Discord {
|
||||
byte[] data = new byte[4096];
|
||||
for (;;) {
|
||||
int len = stream.Read(data, 0, 4096);
|
||||
if (len == 0) throw new EndOfStreamException("stream.Read returned 0");
|
||||
if (len == 0) throw new IOException("stream.Read returned 0");
|
||||
|
||||
HandleReceived(data, len);
|
||||
}
|
||||
|
@ -156,7 +156,10 @@ namespace MCGalaxy.Modules.Relay {
|
||||
// SocketException is usually due to complete connection dropout
|
||||
retries = 0;
|
||||
Thread.Sleep(30 * 1000);
|
||||
} catch (Exception ex) {
|
||||
} catch (IOException ex) {
|
||||
// IOException is an expected error, so don't log full details
|
||||
Logger.Log(LogType.Warning, "{0} read error ({1})", RelayName, ex.Message);
|
||||
} catch (Exception ex) {
|
||||
Logger.LogError(RelayName + " relay error", ex);
|
||||
}
|
||||
retries++;
|
||||
|
@ -192,23 +192,13 @@ namespace Sharkbite.Irc
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
//Trap a connection failure
|
||||
listener.Error( ReplyCode.ConnectionFailed, "Connection to server unexpectedly failed.");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
listener.Error( ReplyCode.ConnectionFailed, "Unhandled error: " + ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
//The connection to the IRC server has been closed either
|
||||
//by client request or the server itself closed the connection.
|
||||
client.Close();
|
||||
registered = false;
|
||||
connected = false;
|
||||
listener.Disconnected();
|
||||
connected = false;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
|
@ -77,10 +77,6 @@ namespace Sharkbite.Irc
|
||||
/// </summary>
|
||||
public event RegisteredEventHandler OnRegistered;
|
||||
/// <summary>
|
||||
/// This connection has been closed.
|
||||
/// </summary>
|
||||
public event DisconnectedEventHandler OnDisconnected;
|
||||
/// <summary>
|
||||
/// A Notice type message was sent to a channel.
|
||||
/// </summary>
|
||||
public event PublicNoticeEventHandler OnPublicNotice;
|
||||
@ -204,16 +200,6 @@ namespace Sharkbite.Irc
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Tell listeners that this connection is closed
|
||||
/// </summary>
|
||||
internal void Disconnected()
|
||||
{
|
||||
if( OnDisconnected != null )
|
||||
{
|
||||
OnDisconnected();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Tell listeners that an error has been encountered
|
||||
/// </summary>
|
||||
internal void Error( ReplyCode code, string message )
|
||||
|
@ -118,11 +118,6 @@ namespace Sharkbite.Irc
|
||||
/// </summary>
|
||||
ERR_USERSDONTMATCH = 502,
|
||||
|
||||
/// <summary>
|
||||
/// When the TCP/IP connection unexpectedly fails.
|
||||
/// </summary>
|
||||
ConnectionFailed = 1000,
|
||||
|
||||
/// <summary>
|
||||
/// The IRC server sent an 'ERROR' message for some
|
||||
/// reason.
|
||||
|
Loading…
x
Reference in New Issue
Block a user