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

Update error message for GeneralHttpException to include the status code #530

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion TMDbLib/Objects/Exceptions/GeneralHttpException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class GeneralHttpException : TMDbException
public HttpStatusCode HttpStatusCode { get; }

public GeneralHttpException(HttpStatusCode httpStatusCode)
: base("TMDb returned an unexpected HTTP error")
: base($"TMDb returned an unexpected HTTP error: {(int)httpStatusCode}")
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really need the explicit conversion to int?

Copy link
Contributor Author

@revam revam Jan 20, 2025

Choose a reason for hiding this comment

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

I did that to be on the safe side in case a status code returned from upstream is not part of the HttpStatusCode enum. If we don't cast to an int (or any other numerical type for that matter), then it will try to convert the value to the value's name when it stringifies it, but I don't and didn't remember how the runtime handles out of bounds values when stringifying, so for consistency's sake I would rather have it always print out the status code in it's numerical form. If you feel it's too much then we can drop the type cast.

An example of a status code not part of the enum (within is codebase even) is 429 (too many requests).

{
HttpStatusCode = httpStatusCode;
}
Expand Down
Loading