aboutsummaryrefslogtreecommitdiff
path: root/mediawiki.lrdevplugin
diff options
context:
space:
mode:
authorRobin Krahl <me@robin-krahl.de>2014-11-01 16:32:42 +0100
committerRobin Krahl <me@robin-krahl.de>2014-11-01 16:32:42 +0100
commitdc549a9f58779a019ea9186002c3867911fcf81b (patch)
tree98a541250fd9d452c3ee373968396c2d3ce41d22 /mediawiki.lrdevplugin
parente1257f32eec1503c1230c4f4642bf2e0bafb7aa4 (diff)
downloadLrMediaWiki-dc549a9f58779a019ea9186002c3867911fcf81b.tar.gz
LrMediaWiki-dc549a9f58779a019ea9186002c3867911fcf81b.tar.bz2
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
Diffstat (limited to 'mediawiki.lrdevplugin')
-rwxr-xr-xmediawiki.lrdevplugin/MediaWikiApi.lua6
-rwxr-xr-xmediawiki.lrdevplugin/TranslatedStrings_de.txt1
2 files changed, 5 insertions, 2 deletions
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!"