Skip to content

Commit f36ca37

Browse files
authored
Merge PR #432: Throw ArgumentNullException in BZip2
Change the BZip2 Compress/Decompress functions to throw ArgumentNullxception rather than Exception when null stream parameters are provided
1 parent 9df6f42 commit f36ca37

File tree

1 file changed

+10
-8
lines changed
  • src/ICSharpCode.SharpZipLib/BZip2

1 file changed

+10
-8
lines changed

src/ICSharpCode.SharpZipLib/BZip2/BZip2.cs

+10-8
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ public static class BZip2
1717
/// <param name="isStreamOwner">Both streams are closed on completion if true.</param>
1818
public static void Decompress(Stream inStream, Stream outStream, bool isStreamOwner)
1919
{
20-
if (inStream == null || outStream == null)
21-
{
22-
throw new Exception("Null Stream");
23-
}
20+
if (inStream == null)
21+
throw new ArgumentNullException(nameof(inStream));
22+
23+
if (outStream == null)
24+
throw new ArgumentNullException(nameof(outStream));
2425

2526
try
2627
{
@@ -51,10 +52,11 @@ public static void Decompress(Stream inStream, Stream outStream, bool isStreamOw
5152
/// the lowest compression and 9 the highest.</param>
5253
public static void Compress(Stream inStream, Stream outStream, bool isStreamOwner, int level)
5354
{
54-
if (inStream == null || outStream == null)
55-
{
56-
throw new Exception("Null Stream");
57-
}
55+
if (inStream == null)
56+
throw new ArgumentNullException(nameof(inStream));
57+
58+
if (outStream == null)
59+
throw new ArgumentNullException(nameof(outStream));
5860

5961
try
6062
{

0 commit comments

Comments
 (0)