Skip to content

Commit 873f6d4

Browse files
committed
Throw clear exception when wrapping the output stream returns null
1 parent e604418 commit 873f6d4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Serilog.Sinks.File/Sinks/File/FileSink.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2013-2016 Serilog Contributors
1+
// Copyright 2013-2016 Serilog Contributors
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -73,6 +73,11 @@ public FileSink(string path, ITextFormatter textFormatter, long? fileSizeLimitBy
7373
if (hooks != null)
7474
{
7575
outputStream = hooks.Wrap(outputStream);
76+
77+
if (outputStream == null)
78+
{
79+
throw new InvalidOperationException($"{hooks.GetType().Name}.Wrap returned null when wrapping the output stream");
80+
}
7681
}
7782

7883
_output = new StreamWriter(outputStream, encoding ?? new UTF8Encoding(encoderShouldEmitUTF8Identifier: false));

0 commit comments

Comments
 (0)