[PR #990] Make all library exceptions inherit from SharpCompressException #1411

Open
opened 2026-01-29 22:20:26 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/adamhathcock/sharpcompress/pull/990

State: closed
Merged: Yes


  • Explore repository and understand current exception hierarchy
  • Build and test current state (526 tests pass)
  • Identify exceptions that need to be updated
  • Update DataErrorException to inherit from SharpCompressException
  • Update InvalidParamException to inherit from SharpCompressException
  • Update XZIndexMarkerReachedException to inherit from SharpCompressException
  • Add tests to verify new exception hierarchy
  • Build and test changes (530 tests pass)
  • Format code with CSharpier
  • Request code review (no issues found)
  • Run security checks (no vulnerabilities)

Summary:
Successfully implemented library-wise exception type hierarchy. All SharpCompress exceptions now inherit from SharpCompressException, allowing users to catch library-specific exceptions without masking unrelated errors.

Changes made:

  1. DataErrorException (LZMA) - now inherits from SharpCompressException
  2. InvalidParamException (LZMA) - now inherits from SharpCompressException
  3. XZIndexMarkerReachedException (XZ) - now inherits from SharpCompressException
  4. Added comprehensive test suite to verify exception hierarchy
  5. Applied CSharpier formatting to all code

Testing:

  • All 530 tests pass
  • Code review: No issues
  • Security scan: No vulnerabilities
Original prompt

This section details on the original issue you should resolve

<issue_title>Library-wise exception type</issue_title>
<issue_description>Please consider declaring a common exception type for the library (like SharpCompressException) and inheriting all specific exception types from it instead of subclassing base Exception class in different places.
It would improve user experience, as now users need to catch (Exception) which could mask actual errors such as hypothetical NullReferenceException in SharpCompress or exceptions thrown from some unrelated code residing in the same try block.</issue_description>

Comments on the Issue (you are @copilot in this section)

@adamhathcock Sounds good @adamhathcock Base exception: `SharpCompressException` from `ApplicationException`

Need to see what other exceptions I define as there seem to be some specific ones but mostly using framework ones</comment_new>
<comment_new>@adamhathcock
You're right. Not sure why I thought it was a good idea.

I also forgot the PR</comment_new>


Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

**Original Pull Request:** https://github.com/adamhathcock/sharpcompress/pull/990 **State:** closed **Merged:** Yes --- - [x] Explore repository and understand current exception hierarchy - [x] Build and test current state (526 tests pass) - [x] Identify exceptions that need to be updated - [x] Update DataErrorException to inherit from SharpCompressException - [x] Update InvalidParamException to inherit from SharpCompressException - [x] Update XZIndexMarkerReachedException to inherit from SharpCompressException - [x] Add tests to verify new exception hierarchy - [x] Build and test changes (530 tests pass) - [x] Format code with CSharpier - [x] Request code review (no issues found) - [x] Run security checks (no vulnerabilities) **Summary:** Successfully implemented library-wise exception type hierarchy. All SharpCompress exceptions now inherit from `SharpCompressException`, allowing users to catch library-specific exceptions without masking unrelated errors. **Changes made:** 1. `DataErrorException` (LZMA) - now inherits from `SharpCompressException` 2. `InvalidParamException` (LZMA) - now inherits from `SharpCompressException` 3. `XZIndexMarkerReachedException` (XZ) - now inherits from `SharpCompressException` 4. Added comprehensive test suite to verify exception hierarchy 5. Applied CSharpier formatting to all code **Testing:** - All 530 tests pass - Code review: No issues - Security scan: No vulnerabilities <!-- START COPILOT CODING AGENT SUFFIX --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>Library-wise exception type</issue_title> > <issue_description>Please consider declaring a common exception type for the library (like SharpCompressException) and inheriting all specific exception types from it instead of subclassing base Exception class in different places. > It would improve user experience, as now users need to `catch (Exception)` which could mask actual errors such as hypothetical NullReferenceException in SharpCompress or exceptions thrown from some unrelated code residing in the same try block.</issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > <comment_new><author>@adamhathcock</author><body> > Sounds good</body></comment_new> > <comment_new><author>@adamhathcock</author><body> > Base exception: > `SharpCompressException` from `ApplicationException` > > Need to see what other exceptions I define as there seem to be some specific ones but mostly using framework ones</body></comment_new> > <comment_new><author>@adamhathcock</author><body> > You're right. Not sure why I thought it was a good idea. > > I also forgot the PR</body></comment_new> > </comments> > </details> - Fixes adamhathcock/sharpcompress#830 <!-- START COPILOT CODING AGENT TIPS --> --- ✨ Let Copilot coding agent [set things up for you](https://github.com/adamhathcock/sharpcompress/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo.
claunia added the pull-request label 2026-01-29 22:20:26 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#1411