Skip to content

Commit 12c265e

Browse files
committed
Throw sink init exceptions
Currently exceptions that occurr during automatic db or table creation when the sink is initialized, are not thrown to the caller/client program. This could hide or delay fatal problems from showing and was changed in this commit. Related: #478
1 parent aef964a commit 12c265e

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/Serilog.Sinks.MSSqlServer/Sinks/MSSqlServer/Platform/SqlCommandExecutor.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public void Execute()
3232
catch (Exception ex)
3333
{
3434
HandleException(ex);
35+
throw;
3536
}
3637
}
3738

test/Serilog.Sinks.MSSqlServer.Tests/Sinks/MSSqlServer/Platform/SqlCommandExecutorTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public void HandlesExceptionFromSqlWriter()
100100
};
101101

102102
// Act
103-
_sut.Execute();
103+
Assert.Throws<InvalidOperationException>(() => _sut.Execute());
104104

105105
// Assert
106106
Assert.True(handlerCalled);
@@ -124,7 +124,7 @@ public void HandlesExceptionFromConnectionFactory()
124124
};
125125

126126
// Act
127-
_sut.Execute();
127+
Assert.Throws<InvalidOperationException>(() => _sut.Execute());
128128

129129
// Assert
130130
Assert.True(handlerCalled);
@@ -148,7 +148,7 @@ public void HandlesExceptionFromConnection()
148148
};
149149

150150
// Act
151-
_sut.Execute();
151+
Assert.Throws<InvalidOperationException>(() => _sut.Execute());
152152

153153
// Assert
154154
Assert.True(handlerCalled);
@@ -172,7 +172,7 @@ public void HandlesExceptionFromCommand()
172172
};
173173

174174
// Act
175-
_sut.Execute();
175+
Assert.Throws<InvalidOperationException>(() => _sut.Execute());
176176

177177
// Assert
178178
Assert.True(handlerCalled);

0 commit comments

Comments
 (0)