Store: Display the error code in case of error downloading the json.

See #14572
This commit is contained in:
Henrik Rydgård 2021-08-22 12:21:44 +02:00
parent 08561a2391
commit 821a6a60aa
3 changed files with 5 additions and 2 deletions

View File

@ -144,6 +144,7 @@ private:
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_;

View File

@ -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);
@ -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();
@ -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);

View File

@ -92,6 +92,7 @@ private:
bool loading_ = true;
bool connectionError_ = false;
int resultCode_ = 0;
std::map<std::string, StoreCategory> categories_;