Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 28, 2025

  • 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.

Copilot AI and others added 2 commits October 28, 2025 10:15
Co-authored-by: adamhathcock <527620+adamhathcock@users.noreply.github.com>
Co-authored-by: adamhathcock <527620+adamhathcock@users.noreply.github.com>
Copilot AI changed the title [WIP] Add common exception type for library Make all library exceptions inherit from SharpCompressException Oct 28, 2025
Copilot AI requested a review from adamhathcock October 28, 2025 10:20
@adamhathcock adamhathcock marked this pull request as ready for review October 28, 2025 11:09
@adamhathcock
Copy link
Owner

@copilot format the code

Co-authored-by: adamhathcock <527620+adamhathcock@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Oct 28, 2025

@copilot format the code

Formatted with CSharpier (210978e)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Library-wise exception type

2 participants