From ed4099eb126afe4e6f05aaf29b84e614ba520c6e Mon Sep 17 00:00:00 2001 From: Pat Hartl Date: Fri, 10 Nov 2023 23:36:14 -0600 Subject: [PATCH] Throw ReaderCancelledException on reader cancelled --- .../Common/ReaderCancelledException.cs | 13 +++++++++++++ src/SharpCompress/Readers/AbstractReader.cs | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 src/SharpCompress/Common/ReaderCancelledException.cs diff --git a/src/SharpCompress/Common/ReaderCancelledException.cs b/src/SharpCompress/Common/ReaderCancelledException.cs new file mode 100644 index 00000000..91e59289 --- /dev/null +++ b/src/SharpCompress/Common/ReaderCancelledException.cs @@ -0,0 +1,13 @@ +using System; + +namespace SharpCompress.Common; + +public class ReaderCancelledException : Exception + +{ + public ReaderCancelledException(string message) + : base(message) { } + + public ReaderCancelledException(string message, Exception inner) + : base(message, inner) { } +} diff --git a/src/SharpCompress/Readers/AbstractReader.cs b/src/SharpCompress/Readers/AbstractReader.cs index 7927937f..285f0f84 100644 --- a/src/SharpCompress/Readers/AbstractReader.cs +++ b/src/SharpCompress/Readers/AbstractReader.cs @@ -75,7 +75,7 @@ public bool MoveToNextEntry() } if (Cancelled) { - throw new InvalidOperationException("Reader has been cancelled."); + throw new ReaderCancelledException("Reader has been cancelled."); } if (entriesForCurrentReadStream is null) {