From 0a7fa788b33b24da8dcc33f1caef7b193444d3fd Mon Sep 17 00:00:00 2001 From: David Sansome Date: Mon, 13 Sep 2010 23:52:05 +0000 Subject: [PATCH] On second thoughts, lose the gotos and handle the last.fm errors by throwing. --- src/core/albumcoverfetcher.cpp | 5 +---- src/radio/lastfmservice.cpp | 21 ++++----------------- 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/src/core/albumcoverfetcher.cpp b/src/core/albumcoverfetcher.cpp index 2038bc0b2..6f79316c9 100644 --- a/src/core/albumcoverfetcher.cpp +++ b/src/core/albumcoverfetcher.cpp @@ -106,7 +106,7 @@ void AlbumCoverFetcher::AlbumSearchFinished() { lastfm::XmlQuery query(lastfm::ws::parse(reply)); #ifdef Q_OS_WIN32 if (lastfm::ws::last_parse_error != lastfm::ws::NoError) - goto lastfm_error; + throw std::runtime_error(""); #endif // Parse the list of search results @@ -138,9 +138,6 @@ void AlbumCoverFetcher::AlbumSearchFinished() { active_requests_[image_reply] = request; } catch (std::runtime_error&) { -#ifdef Q_OS_WIN32 - lastfm_error: -#endif if (request.search) emit SearchFinished(request.id, AlbumCoverFetcher::SearchResults()); else diff --git a/src/radio/lastfmservice.cpp b/src/radio/lastfmservice.cpp index 8490ee0b2..cfed16494 100644 --- a/src/radio/lastfmservice.cpp +++ b/src/radio/lastfmservice.cpp @@ -212,15 +212,12 @@ void LastFMService::AuthenticateReplyFinished() { lastfm::XmlQuery const lfm = lastfm::ws::parse(reply); #ifdef Q_OS_WIN32 if (lastfm::ws::last_parse_error != lastfm::ws::NoError) - goto lastfm_error; + throw std::runtime_error(""); #endif lastfm::ws::Username = lfm["session"]["name"].text(); lastfm::ws::SessionKey = lfm["session"]["key"].text(); } catch (std::runtime_error& e) { -#ifdef Q_OS_WIN32 - lastfm_error: -#endif qDebug() << e.what(); emit AuthenticationComplete(false); return; @@ -503,12 +500,9 @@ void LastFMService::RefreshFriendsFinished() { friends = lastfm::User::list(reply); #ifdef Q_OS_WIN32 if (lastfm::ws::last_parse_error != lastfm::ws::NoError) - goto lastfm_error; + throw std::runtime_error(""); #endif } catch (std::runtime_error& e) { -#ifdef Q_OS_WIN32 - lastfm_error: -#endif qDebug() << e.what(); return; } @@ -532,12 +526,9 @@ void LastFMService::RefreshNeighboursFinished() { neighbours = lastfm::User::list(reply); #ifdef Q_OS_WIN32 if (lastfm::ws::last_parse_error != lastfm::ws::NoError) - goto lastfm_error; + throw std::runtime_error(""); #endif } catch (std::runtime_error& e) { -#ifdef Q_OS_WIN32 - lastfm_error: -#endif qDebug() << e.what(); return; } @@ -648,7 +639,7 @@ void LastFMService::FetchMoreTracksFinished() { const XmlQuery& query = lastfm::ws::parse(reply); #ifdef Q_OS_WIN32 if (lastfm::ws::last_parse_error != lastfm::ws::NoError) - goto lastfm_error; + throw std::runtime_error(""); #endif const XmlQuery& playlist = query["playlist"]; @@ -666,10 +657,6 @@ void LastFMService::FetchMoreTracksFinished() { playlist_ << t; } } catch (std::runtime_error& e) { -#ifdef Q_OS_WIN32 - lastfm_error: -#endif - // For some reason a catch block that takes a lastfm::ws::ParseError& // doesn't get called, even when a lastfm::ws::ParseError is thrown... // Hacks like this remind me of Java...