From dc549a9f58779a019ea9186002c3867911fcf81b Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Sat, 1 Nov 2014 16:32:42 +0100 Subject: Check for empty HTTP status Raise a specific error if the HTTP status is empty. This indicates that there is no internet connection or that the MediaWiki installation cannot be reached. Previously, the error message just reported an empty HTTP status. - check for empty HTTP status in `MediaWikiApi` Fix https://github.com/ireas/LrMediaWiki/issues/28 --- mediawiki.lrdevplugin/MediaWikiApi.lua | 6 ++++-- mediawiki.lrdevplugin/TranslatedStrings_de.txt | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'mediawiki.lrdevplugin') diff --git a/mediawiki.lrdevplugin/MediaWikiApi.lua b/mediawiki.lrdevplugin/MediaWikiApi.lua index 33ae9a6..cc1c322 100755 --- a/mediawiki.lrdevplugin/MediaWikiApi.lua +++ b/mediawiki.lrdevplugin/MediaWikiApi.lua @@ -90,8 +90,10 @@ function MediaWikiApi.performRequest(arguments) } local resultBody, resultHeaders = LrHttp.post(MediaWikiApi.apiPath, requestBody, requestHeaders) - - if resultHeaders.status ~= 200 then + + if not resultHeaders.status then + LrErrors.throwUserError(LOC('$$$/LrMediaWiki/Api/NoConnection=Cannot connect to the MediaWiki API.')) + elseif resultHeaders.status ~= 200 then LrErrors.throwUserError(LOC('$$$/LrMediaWiki/Api/HttpError=Received HTTP status ^1.', resultHeaders.status)) end diff --git a/mediawiki.lrdevplugin/TranslatedStrings_de.txt b/mediawiki.lrdevplugin/TranslatedStrings_de.txt index a662099..043f761 100755 --- a/mediawiki.lrdevplugin/TranslatedStrings_de.txt +++ b/mediawiki.lrdevplugin/TranslatedStrings_de.txt @@ -1,5 +1,6 @@ "$$$/LrMediaWiki/Api/HttpError=HTTP-Status ^1 erhalten." "$$$/LrMediaWiki/Api/MediaWikiError=Der MediaWiki-Fehler ^1 ist aufgetreten: ^2" +"$$$/LrMediaWiki/Api/NoConnection=Kann keine Verbindung zur MediaWiki-API aufbauen." "$$$/LrMediaWiki/Export/DescriptionError=Fehler beim Lesen der Dateibeschreibung" "$$$/LrMediaWiki/Export/NoApiPath=Kein API-Pfad angegeben!" "$$$/LrMediaWiki/Export/NoAuthor=Kein Urheber angegeben!" -- cgit v1.2.3