From d92040b804aaacfcf03da5f361d0fd26b6df3d54 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Thu, 4 Apr 2019 11:36:12 +0100 Subject: [PATCH] Add error message if catalog invalid json --- CHANGELOG.md | 1 + .../editor-client/src/js/ui/palette-editor.js | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 79847be90..5889d736b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ - Add explanation to the help text on the new feature to build query string from msg.payload #2116 - Bump bcrypt to latest - Add Korean locales files for nodes #2100 +- Add error message if catalog is invalid json #### 0.20.3: Maintenance Release diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/palette-editor.js b/packages/node_modules/@node-red/editor-client/src/js/ui/palette-editor.js index d04e460d8..cdea06b77 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/palette-editor.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/palette-editor.js @@ -382,9 +382,20 @@ RED.palette.editor = (function() { catalogueLoadStart = Date.now(); var handled = 0; catalogues.forEach(function(catalog,index) { - $.getJSON(catalog, {_: new Date().getTime()},function(v) { - handleCatalogResponse(null,catalog,index,v); - refreshNodeModuleList(); + $.ajax({ + dataType: "json", + url: catalog, + data: {_: new Date().getTime()}, + success: function(v) { + try { + var parsed = JSON.parse(v); + handleCatalogResponse(null,catalog,index,parsed); + refreshNodeModuleList(); + } catch(err) { + console.error(catalog,err.toString()) + handleCatalogResponse(err,catalog,index); + } + } }).fail(function(jqxhr, textStatus, error) { handleCatalogResponse(jqxhr,catalog,index); }).always(function() {