Skip to content

Commit

Permalink
Store: Display the error code in case of error downloading the json.
Browse files Browse the repository at this point in the history
See #14572
  • Loading branch information
hrydgard committed Aug 22, 2021
1 parent 08561a2 commit 821a6a6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions Common/Net/HTTPClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ class Download {
int PerformGET(const std::string &url);
std::string RedirectLocation(const std::string &baseUrl);
void SetFailed(int code);

RequestProgress progress_;
Buffer buffer_;
std::vector<std::string> responseHeaders_;
Expand Down
5 changes: 3 additions & 2 deletions UI/Store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ void StoreScreen::update() {
g_DownloadManager.Update();

if (listing_.get() != 0 && listing_->Done()) {
resultCode_ = listing_->ResultCode();
if (listing_->ResultCode() == 200) {
std::string listingJson;
listing_->buffer().TakeAll(&listingJson);
Expand All @@ -392,7 +393,7 @@ void StoreScreen::update() {
RecreateViews();
} else {
// Failed to contact store. Don't do anything.
ERROR_LOG(IO, "Download failed : error code %d", listing_->ResultCode());
ERROR_LOG(IO, "Download failed : error code %d", resultCode_);
connectionError_ = true;
loading_ = false;
RecreateViews();
Expand Down Expand Up @@ -468,7 +469,7 @@ void StoreScreen::CreateViews() {
LinearLayout *content;
if (connectionError_ || loading_) {
content = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT, 1.0f));
content->Add(new TextView(loading_ ? st->T("Loading...") : st->T("Connection Error")));
content->Add(new TextView(loading_ ? std::string(st->T("Loading...")) : StringFromFormat("%s: %d", st->T("Connection Error"), resultCode_)));
content->Add(new Button(di->T("Retry")))->OnClick.Handle(this, &StoreScreen::OnRetry);
content->Add(new Button(di->T("Back")))->OnClick.Handle<UIScreen>(this, &UIScreen::OnBack);

Expand Down
1 change: 1 addition & 0 deletions UI/Store.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class StoreScreen : public UIDialogScreenWithBackground {

bool loading_ = true;
bool connectionError_ = false;
int resultCode_ = 0;

std::map<std::string, StoreCategory> categories_;

Expand Down

1 comment on commit 821a6a6

@hrydgard
Copy link
Owner Author

Choose a reason for hiding this comment

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

This commit was just to display the error code.

Please sign in to comment.