Skip to content

Conversation

rfc2822
Copy link
Member

@rfc2822 rfc2822 commented Sep 3, 2025

Addresses the DavException and HttpException issues mentioned in #93:

  • Exception data is now immutable (and only consists of serializable data types).
  • HttpException is guaranteed to have a status code. The status codes 3xx, 4xx and 5xx can now explicitly be detected by isRedirect etc., as this is often used by DAVx⁵.

Extracting the HTTP information (status code request/response excerpt) has been moved to a separate class which is also tested separately.

@rfc2822 rfc2822 linked an issue Sep 3, 2025 that may be closed by this pull request
@rfc2822 rfc2822 added the refactoring Internal improvement of existing functions label Sep 3, 2025
@rfc2822 rfc2822 linked an issue Sep 3, 2025 that may be closed by this pull request
@rfc2822 rfc2822 force-pushed the 93-httpexceptionstatuscode-may-be-null branch from 35f3fe7 to 5d708cc Compare September 4, 2025 08:55
@rfc2822 rfc2822 force-pushed the 93-httpexceptionstatuscode-may-be-null branch from 5d708cc to b6648bb Compare September 4, 2025 08:56
@rfc2822 rfc2822 self-assigned this Sep 4, 2025
@rfc2822 rfc2822 requested a review from Copilot September 4, 2025 08:57
Copilot

This comment was marked as outdated.

@rfc2822 rfc2822 requested a review from Copilot September 4, 2025 09:02
@rfc2822 rfc2822 changed the title Make DavException and HttpException immutable and make sure that HttpException always has a status code Make DavException and HttpException immutable; HttpException always has a status code Sep 4, 2025
@rfc2822 rfc2822 changed the title Make DavException and HttpException immutable; HttpException always has a status code Make DavException and HttpException immutable; provide status code for HttpException Sep 4, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the DavException and HttpException classes to make them immutable and ensures HttpException always has a status code. The refactoring extracts HTTP response information processing into a separate HttpResponseInfo class to improve separation of concerns and testability.

Key changes:

  • Made exception data immutable by converting mutable properties to constructor parameters
  • Extracted HTTP response processing logic into HttpResponseInfo class with comprehensive test coverage
  • Ensured HttpException always has a non-null status code through constructor design

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/main/kotlin/at/bitfire/dav4jvm/exception/DavException.kt Refactored to use immutable properties and delegate HTTP processing to HttpResponseInfo
src/main/kotlin/at/bitfire/dav4jvm/exception/HttpException.kt Made immutable with guaranteed status code and added convenience properties for status classification
src/main/kotlin/at/bitfire/dav4jvm/exception/HttpResponseInfo.kt New class extracting HTTP response processing logic with proper text/XML detection
src/test/kotlin/at/bitfire/dav4jvm/exception/DavExceptionTest.kt Simplified tests to focus on constructor behavior and serialization
src/test/kotlin/at/bitfire/dav4jvm/exception/HttpExceptionTest.kt New comprehensive tests for HttpException functionality
src/test/kotlin/at/bitfire/dav4jvm/exception/HttpResponseInfoTest.kt New comprehensive tests for HttpResponseInfo extraction logic
src/test/kotlin/at/bitfire/dav4jvm/exception/ServiceUnavailableExceptionTest.kt Minor formatting improvements to request builder

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@rfc2822 rfc2822 marked this pull request as ready for review September 4, 2025 09:07
@rfc2822 rfc2822 requested review from sunkup and ArnyminerZ September 4, 2025 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Internal improvement of existing functions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HttpException.statusCode may be null
1 participant