Skip to content

Commit 391663a

Browse files
committed
Replaced NotImplementedException for streams
Especially for streams, it is more appropriate to throw NotSupportedException instead of NotImplementedException. Usually consumers of streams expect NotSupportedException to handle errors. There are other places that also use NotImplementedException but I didn't examine them for now. I only modified stream classes in SharpCompress.IO. For reference about this best practise, please see these articles: http://blogs.msdn.com/b/brada/archive/2004/07/29/201354.aspx http://blogs.msdn.com/b/jaredpar/archive/2008/12/12/notimplementedexception-vs-notsupportedexception.aspx
1 parent a8c055b commit 391663a

File tree

4 files changed

+24
-24
lines changed

4 files changed

+24
-24
lines changed

SharpCompress/IO/CountingWritableSubStream.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,28 +35,28 @@ public override void Flush()
3535

3636
public override long Length
3737
{
38-
get { throw new NotImplementedException(); }
38+
get { throw new NotSupportedException(); }
3939
}
4040

4141
public override long Position
4242
{
43-
get { throw new NotImplementedException(); }
44-
set { throw new NotImplementedException(); }
43+
get { throw new NotSupportedException(); }
44+
set { throw new NotSupportedException(); }
4545
}
4646

4747
public override int Read(byte[] buffer, int offset, int count)
4848
{
49-
throw new NotImplementedException();
49+
throw new NotSupportedException();
5050
}
5151

5252
public override long Seek(long offset, SeekOrigin origin)
5353
{
54-
throw new NotImplementedException();
54+
throw new NotSupportedException();
5555
}
5656

5757
public override void SetLength(long value)
5858
{
59-
throw new NotImplementedException();
59+
throw new NotSupportedException();
6060
}
6161

6262
public override void Write(byte[] buffer, int offset, int count)

SharpCompress/IO/MarkingBinaryReader.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ public void Mark()
2121

2222
public override int Read()
2323
{
24-
throw new NotImplementedException();
24+
throw new NotSupportedException();
2525
}
2626

2727
public override int Read(byte[] buffer, int index, int count)
2828
{
29-
throw new NotImplementedException();
29+
throw new NotSupportedException();
3030
}
3131

3232
public override int Read(char[] buffer, int index, int count)
3333
{
34-
throw new NotImplementedException();
34+
throw new NotSupportedException();
3535
}
3636

3737
public override bool ReadBoolean()
@@ -57,12 +57,12 @@ public override byte[] ReadBytes(int count)
5757

5858
public override char ReadChar()
5959
{
60-
throw new NotImplementedException();
60+
throw new NotSupportedException();
6161
}
6262

6363
public override char[] ReadChars(int count)
6464
{
65-
throw new NotImplementedException();
65+
throw new NotSupportedException();
6666
}
6767

6868
#if !PORTABLE
@@ -115,7 +115,7 @@ public override float ReadSingle()
115115

116116
public override string ReadString()
117117
{
118-
throw new NotImplementedException();
118+
throw new NotSupportedException();
119119
}
120120

121121
public override ushort ReadUInt16()

SharpCompress/IO/ReadOnlySubStream.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,18 @@ public override bool CanWrite
4848

4949
public override void Flush()
5050
{
51-
throw new System.NotImplementedException();
51+
throw new System.NotSupportedException();
5252
}
5353

5454
public override long Length
5555
{
56-
get { throw new System.NotImplementedException(); }
56+
get { throw new System.NotSupportedException(); }
5757
}
5858

5959
public override long Position
6060
{
61-
get { throw new System.NotImplementedException(); }
62-
set { throw new System.NotImplementedException(); }
61+
get { throw new System.NotSupportedException(); }
62+
set { throw new System.NotSupportedException(); }
6363
}
6464

6565
public override int Read(byte[] buffer, int offset, int count)
@@ -78,17 +78,17 @@ public override int Read(byte[] buffer, int offset, int count)
7878

7979
public override long Seek(long offset, SeekOrigin origin)
8080
{
81-
throw new System.NotImplementedException();
81+
throw new System.NotSupportedException();
8282
}
8383

8484
public override void SetLength(long value)
8585
{
86-
throw new System.NotImplementedException();
86+
throw new System.NotSupportedException();
8787
}
8888

8989
public override void Write(byte[] buffer, int offset, int count)
9090
{
91-
throw new System.NotImplementedException();
91+
throw new System.NotSupportedException();
9292
}
9393
}
9494
}

SharpCompress/IO/RewindableStream.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ public override bool CanWrite
8484

8585
public override void Flush()
8686
{
87-
throw new System.NotImplementedException();
87+
throw new System.NotSupportedException();
8888
}
8989

9090
public override long Length
9191
{
92-
get { throw new System.NotImplementedException(); }
92+
get { throw new System.NotSupportedException(); }
9393
}
9494

9595
public override long Position
@@ -147,17 +147,17 @@ public override int Read(byte[] buffer, int offset, int count)
147147

148148
public override long Seek(long offset, SeekOrigin origin)
149149
{
150-
throw new System.NotImplementedException();
150+
throw new System.NotSupportedException();
151151
}
152152

153153
public override void SetLength(long value)
154154
{
155-
throw new System.NotImplementedException();
155+
throw new System.NotSupportedException();
156156
}
157157

158158
public override void Write(byte[] buffer, int offset, int count)
159159
{
160-
throw new System.NotImplementedException();
160+
throw new System.NotSupportedException();
161161
}
162162
}
163163
}

0 commit comments

Comments
 (0)