1
0
mirror of https://github.com/winscp/winscp.git synced 2026-10-24 02:28:55 +03:00
Files
winscp/dotnet/internal/SessionElementLogReader.cs
Martin Prikryl 3826bbdf31 Logging exceptions
Source commit: ebd1d9a5e3cfcaaa3e48c591734b870135bf633c
2018-01-28 04:54:07 +01:00

36 lines
895 B
C#

namespace WinSCP
{
internal class SessionElementLogReader : ElementLogReader
{
public SessionElementLogReader(CustomLogReader parentReader) :
base(parentReader)
{
}
public override void Dispose()
{
using (Session.Logger.CreateCallstack())
{
// Now it's ok if we encounter </session>.
_disposing = true;
base.Dispose();
}
}
public override bool Read(LogReadFlags flags)
{
bool result = base.Read(flags);
if (_read && !_disposing)
{
throw Session.Logger.WriteException(new SessionLocalException(Session, "Session has unexpectedly closed"));
}
return result;
}
private bool _disposing;
}
}