Commit e023540 1 parent f28f419 commit e023540 Copy full SHA for e023540
File tree 3 files changed +35
-13
lines changed
3 files changed +35
-13
lines changed Original file line number Diff line number Diff line change 8
8
9
9
* Show the filename of the missing file when ``nikola serve `` can't
10
10
find a file (i.e. when an 404 error occurs).
11
+ * Better error messages for JSON download failures in ``nikola
12
+ plugin `` and ``nikola theme `` (Issue getnikola/plugins#282)
11
13
12
14
Bugfixes
13
15
--------
Original file line number Diff line number Diff line change 27
27
"""Manage plugins."""
28
28
29
29
import io
30
+ import json .decoder
30
31
import os
31
32
import sys
32
33
import shutil
@@ -338,10 +339,19 @@ def get_json(self, url):
338
339
"""Download the JSON file with all plugins."""
339
340
if self .json is None :
340
341
try :
341
- self .json = requests .get (url ).json ()
342
- except requests .exceptions .SSLError :
343
- LOGGER .warning ("SSL error, using http instead of https (press ^C to abort)" )
344
- time .sleep (1 )
345
- url = url .replace ('https' , 'http' , 1 )
346
- self .json = requests .get (url ).json ()
342
+ try :
343
+ self .json = requests .get (url ).json ()
344
+ except requests .exceptions .SSLError :
345
+ LOGGER .warning ("SSL error, using http instead of https (press ^C to abort)" )
346
+ time .sleep (1 )
347
+ url = url .replace ('https' , 'http' , 1 )
348
+ self .json = requests .get (url ).json ()
349
+ except json .decoder .JSONDecodeError as e :
350
+ LOGGER .error ("Failed to decode JSON data in response from server." )
351
+ LOGGER .error ("JSON error encountered: " + str (e ))
352
+ LOGGER .error ("This issue might be caused by server-side issues, or by to unusual activity in your "
353
+ "network (as determined by CloudFlare). Please visit https://plugins.getnikola.com/ in "
354
+ "a browser." )
355
+ sys .exit (2 )
356
+
347
357
return self .json
Original file line number Diff line number Diff line change 26
26
27
27
"""Manage themes."""
28
28
29
- import os
30
29
import io
30
+ import json .decoder
31
+ import os
31
32
import shutil
32
33
import time
33
34
import requests
@@ -374,10 +375,19 @@ def get_json(self, url):
374
375
"""Download the JSON file with all plugins."""
375
376
if self .json is None :
376
377
try :
377
- self .json = requests .get (url ).json ()
378
- except requests .exceptions .SSLError :
379
- LOGGER .warning ("SSL error, using http instead of https (press ^C to abort)" )
380
- time .sleep (1 )
381
- url = url .replace ('https' , 'http' , 1 )
382
- self .json = requests .get (url ).json ()
378
+ try :
379
+ self .json = requests .get (url ).json ()
380
+ except requests .exceptions .SSLError :
381
+ LOGGER .warning ("SSL error, using http instead of https (press ^C to abort)" )
382
+ time .sleep (1 )
383
+ url = url .replace ('https' , 'http' , 1 )
384
+ self .json = requests .get (url ).json ()
385
+ except json .decoder .JSONDecodeError as e :
386
+ LOGGER .error ("Failed to decode JSON data in response from server." )
387
+ LOGGER .error ("JSON error encountered:" + str (e ))
388
+ LOGGER .error ("This issue might be caused by server-side issues, or by to unusual activity in your "
389
+ "network (as determined by CloudFlare). Please visit https://themes.getnikola.com/ in "
390
+ "a browser." )
391
+ sys .exit (2 )
392
+
383
393
return self .json
You can’t perform that action at this time.
0 commit comments