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

More descriptive exception in WriteShortstr #908

Merged
merged 2 commits into from
Jul 10, 2020

Conversation

tmasternak
Copy link
Contributor

@tmasternak tmasternak commented Jul 10, 2020

Proposed Changes

This change wraps the ArgumentException throw by Encoding.UTF8.GetBytes when there is not enough space in the output buffer provided. ArgumentException doesn't give any indication on the string value passed to the WriteShortstr which makes it hard for the user to figure out what is the root cause of the problem eg. that the name passed to the DeclareQueue method is too long.

Currently, the exception message is:

The output byte buffer is too small to contain the encoded data, encoding 'Unicode (UTF-8)' fallback
'System.Text.EncoderReplacementFallback'. Parameter name: bytes

With the change the exception message is:

System.ArgumentOutOfRangeException : Value exceeds the maximum allowed length of 255 bytes. Parameter name: val Actual value was value

Types of Changes

What types of changes does your code introduce to this project?
Put an x in the boxes that apply

Checklist

  • I have read the CONTRIBUTING.md document
  • I have signed the CA (see https://cla.pivotal.io/sign/rabbitmq)
  • All tests pass locally with my changes
  • I have added changed tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in related repositories

tmasternak and others added 2 commits July 9, 2020 13:14
Co-authored-by: ramonsmits <ramon.smits@gmail.com>
@pivotal-issuemaster
Copy link

@tmasternak Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

@pivotal-issuemaster
Copy link

@tmasternak Thank you for signing the Contributor License Agreement!

@michaelklishin michaelklishin merged commit 19e30bf into rabbitmq:master Jul 10, 2020
michaelklishin added a commit that referenced this pull request Jul 10, 2020
More descriptive exception in WriteShortstr

(cherry picked from commit 19e30bf)
michaelklishin added a commit that referenced this pull request Jul 10, 2020
@lukebakken lukebakken added this to the 7.0.0 milestone Jul 13, 2020
@lukebakken lukebakken modified the milestones: 8.0.0, 7.0.0 Mar 8, 2022
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.

4 participants