Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve exception messages from HttpObjectDecoder #1228

Merged
merged 4 commits into from
Dec 1, 2020

Conversation

idelpivnitskiy
Copy link
Member

Motivation:

HttpObjectDecoder and its subclasses may throw an exception if the received
HTTP message violates the RFC and can not be parsed. However, exception messages
are short and hard to understand, without any pointers to what part of the
message caused an exception. Those cases are hard to debug and usually require
knowledge of RFC.

Modifications:

  • Introduce IllegalCharacterException type that shows an illegal character as
    a char and in hex format, as well as expected values;
  • try-catch an IllegalCharacterException and wrap it with DecoderException
    that clarifies where the illegal character was found;
  • Adjust tests for new exception messages;

Result:

More understandable exception messages from HttpObjectDecoder.

Depends on #1227.

Motivation:

`HttpObjectDecoder` and its subclasses may throw an exception if the received
HTTP message violates the RFC and can not be parsed. However, exception messages
are short and hard to understand, without any pointers to what part of the
message caused an exception. Those cases are hard to debug and usually require
knowledge of RFC.

Modifications:

- Introduce `IllegalCharacterException` type that shows an illegal character as
a `char` and in hex format, as well as an expected values;
- `try-catch` an `IllegalCharacterException` and wrap it with `DecoderException`
that clarifies where the illegal character was found;
- Adjust tests for new exception messages;

Result:

More understandable exception messages from `HttpObjectDecoder`.
Copy link
Contributor

@tkountis tkountis left a comment

Choose a reason for hiding this comment

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

LGTM

@idelpivnitskiy idelpivnitskiy merged commit 8cafd9c into apple:main Dec 1, 2020
@idelpivnitskiy idelpivnitskiy deleted the decoder-exceptions branch December 1, 2020 23:31
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.

3 participants