mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-18 11:48:33 -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];
|
byte[] data = new byte[4096];
|
||||||
for (;;) {
|
for (;;) {
|
||||||
int len = stream.Read(data, 0, 4096);
|
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);
|
HandleReceived(data, len);
|
||||||
}
|
}
|
||||||
|
@ -156,7 +156,10 @@ namespace MCGalaxy.Modules.Relay {
|
|||||||
// SocketException is usually due to complete connection dropout
|
// SocketException is usually due to complete connection dropout
|
||||||
retries = 0;
|
retries = 0;
|
||||||
Thread.Sleep(30 * 1000);
|
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);
|
Logger.LogError(RelayName + " relay error", ex);
|
||||||
}
|
}
|
||||||
retries++;
|
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
|
finally
|
||||||
{
|
{
|
||||||
//The connection to the IRC server has been closed either
|
//The connection to the IRC server has been closed either
|
||||||
//by client request or the server itself closed the connection.
|
//by client request or the server itself closed the connection.
|
||||||
client.Close();
|
client.Close();
|
||||||
registered = false;
|
registered = false;
|
||||||
connected = false;
|
connected = false;
|
||||||
listener.Disconnected();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -77,10 +77,6 @@ namespace Sharkbite.Irc
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public event RegisteredEventHandler OnRegistered;
|
public event RegisteredEventHandler OnRegistered;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This connection has been closed.
|
|
||||||
/// </summary>
|
|
||||||
public event DisconnectedEventHandler OnDisconnected;
|
|
||||||
/// <summary>
|
|
||||||
/// A Notice type message was sent to a channel.
|
/// A Notice type message was sent to a channel.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event PublicNoticeEventHandler OnPublicNotice;
|
public event PublicNoticeEventHandler OnPublicNotice;
|
||||||
@ -204,16 +200,6 @@ namespace Sharkbite.Irc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <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
|
/// Tell listeners that an error has been encountered
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal void Error( ReplyCode code, string message )
|
internal void Error( ReplyCode code, string message )
|
||||||
|
@ -118,11 +118,6 @@ namespace Sharkbite.Irc
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
ERR_USERSDONTMATCH = 502,
|
ERR_USERSDONTMATCH = 502,
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// When the TCP/IP connection unexpectedly fails.
|
|
||||||
/// </summary>
|
|
||||||
ConnectionFailed = 1000,
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The IRC server sent an 'ERROR' message for some
|
/// The IRC server sent an 'ERROR' message for some
|
||||||
/// reason.
|
/// reason.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user