From b85d1be070f756dbe7d7cfce7f0743ecf85e203e Mon Sep 17 00:00:00 2001 From: Sebastian Hammer Date: Wed, 18 Apr 2007 04:23:53 +0000 Subject: [PATCH] Put an alert in ajaxError. This is not pretty and should be moved to the client code.. but I am not sure how Jakub wants to handle errors in the client code. Do we need to clean up what pazpar2 sends back? --- js/pz2.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/js/pz2.js b/js/pz2.js index 6d34ce0..d6d7f7d 100644 --- a/js/pz2.js +++ b/js/pz2.js @@ -1,5 +1,5 @@ /* -** $Id: pz2.js,v 1.9 2007-04-18 04:07:48 quinn Exp $ +** $Id: pz2.js,v 1.10 2007-04-18 04:23:53 quinn Exp $ ** pz2.js - pazpar2's javascript client library. */ @@ -91,9 +91,16 @@ var pz2 = function(paramArray) { // error handling $(document).ajaxError( function (request, settings, exception) { - alert("AjaxErr"); if ( settings.responseXML && settings.responseXML.getElementsByTagName("error") ) - throw new Error( settings.responseXML.getElementsByTagName("error")[0].childNodes[0].nodeValue); + { + var err = settings.responseXML.getElementsByTagName("error")[0].childNodes[0].nodeValue; + if (err == 'QUERY') + alert("Your query was not understood. Please rephrase"); + else + throw new Error( settings.responseXML.getElementsByTagName("error")[0].childNodes[0].nodeValue); + } + else + throw exception; }); // auto init session? -- 1.7.10.4