-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Exceptions don't display default exception messages when ApiError.Message is empty #1529
Comments
Is this related to something I found when working on a PR here: #1415 ? If you see the 2nd bullet point where I talk about the attempted |
Opened octokit#1529 to explore this.
* Add some tests to be completed * Actually fail the tests * Create AbuseException class Copied from ForbiddenException and then gone over to inherit from it. * Actually add AbuseException to csproj * Update test file * Ran .\build FixProjects * Test updates * Default message update for AbuseException * Separate the exception creation logic * Remove message assertion -- doesn't matter here * Additional test for abuse message * Remove unnecessary variable assignment * Failing test for unsafe request * Attempt to fix test Still broken -- I don't think empty strings count to trigger the default message * Remove test that will always fail due to another issue Opened #1529 to explore this. * New tests (some failing) * Passing tests are, like, better than failing tests. * Last passing test * Cleanup * Add test for zero value and fix code Lol boundary cases. * cleanup * Mark ParseRetryAfterSeconds as static * Add GetObjectData override to AbuseException To include data for RetryAfterSeconds variable, and satisfy the build check. * Add back failing test & skip it * Change to nullable int with null default * Fix tests around nullable default * whitespace fixes * Compact the logic; tests still pass * Invert the if statements for compactness / clarity * Test subclasses & reformatting * Test name changes * Whitespace fix * Remove redundant line
Just refreshing my memory with this stuff and yes I agree with your suggestion. Specifically I think the 2nd suggested fix would be the way to go, since we can "fix" it in one place, rather than needing to fix it in every place that currently has And this is a different situation to what I commented about above - in that case I found that a compeltely invalid json structure in the error message was still returning a default/empty |
👍 Got it, makes sense. I'll put together a PR to un-skip this test and fix it via the decision here. |
Currently, many exceptions take
ApiErrorMessageSafe
and display the default text if it's null.However, this should probably also apply if
ApiErrorMessageSafe
is empty so that the user gets something.I came across this while attempting to write out tests for #1528. I didn't want to change too many things in that PR, so figured I'd create this as an off-shoot.
A failing test
Removed this from my previous PR. Expected the default error message (e.g. generic "Request Forbidden") -- actual was an empty string. This was part of
ConnectionTests.cs
in #1528 before I ripped it out:Potential Fixes
Message
property of the affected exceptions to do anIsNullOrWhitespace
check onApiErrorMessageSafe
.ApiErrorMessageSafe
could be changed to return null if the Message string is empty or whitepsace, rather than just returning the message property itself.The text was updated successfully, but these errors were encountered: