[bitbake-devel] [PATCH 08/11] toaster: libtoaster Add a error handler to GET in makeTypehead

Alex DAMIAN alexandru.damian at intel.com
Wed Dec 10 15:12:13 UTC 2014


From: Michael Wood <michael.g.wood at intel.com>

If the JSON data comes back from the request with an error set, have a
default handler which logs the error to the console.

Signed-off-by: Michael Wood <michael.g.wood at intel.com>
---
 lib/toaster/toastergui/static/js/libtoaster.js | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lib/toaster/toastergui/static/js/libtoaster.js b/lib/toaster/toastergui/static/js/libtoaster.js
index 37fc80e..b691a3b 100644
--- a/lib/toaster/toastergui/static/js/libtoaster.js
+++ b/lib/toaster/toastergui/static/js/libtoaster.js
@@ -20,6 +20,11 @@ var libtoaster = (function (){
         source: function(query, process){
           xhrParams.value = query;
           $.getJSON(xhrUrl, this.options.xhrParams, function(data){
+            if (data.error != "ok") {
+              console.log("Error getting data from server "+data.error);
+              return;
+            }
+
             return process (data.list);
           });
         },
-- 
1.9.1




More information about the bitbake-devel mailing list