Bugfix: Return error when http code from tibia is 403 #300
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.








It would love to help a bit with this issue. I'm running tibiadata in my local, and did some tests to reproduce the issue. I think I know why is it failing and returning empty data. In TibiaDataHTMLDataCollector, when the request to Tibia.com is done, there are some checks on the response http code (case http.StatusForbidden:, case http.StatusFound:). But they are done inside this if clause:
This only will be true in case that there is a network error or a timeout, because this refers to an error from the point of view of Resty, the library.
When Tibia.com throttles and returns 403 forbidden, the err variable is still null, so no http code checks are done.
With this changes, instead of returning a response with empty values, a proper error response is returned: