Unverified Commit 7ae867ba authored by User expired's avatar User expired
Browse files

improved error messages

parent 5cd90d73
Upcoming version:
-----------------
- improved error messages (Nikolaus Krismer)
- fixed hill shading and meanCalculator (skewness part) (Nikolaus Krismer)
- fixed time invariant isochrone computation (Nikolaus Krismer)
- fixing findbugs warnings (Nikolaus Krismer)
......
......@@ -853,7 +853,7 @@ define(['jquery', 'leaflet', 'util/loggingUtils', 'isochrone/configuration', 'ma
controlWsWarning.hide();
if (!preventEventAttachment) {
$(document).on('websocket_error', warningIndicatorShow);
//$(document).on('websocket_error', warningIndicatorShow);
$(document).on('websocket_close', warningIndicatorShow);
$(document).on('websocket_open', warningIndicatorHide.bind(this, true));
}
......
/**
* @class ServiceConfiguration
*/
define(['jquery', 'leaflet', 'util/loggingUtils', 'isochrone/configuration', 'util/geoUtils', 'util/stringUtils'], function($, L, logger, Configuration, GeoUtils, StringUtils) {
define(['jquery', 'leaflet', 'util/loggingUtils', 'isochrone/configuration', 'util/geoUtils', 'util/stringUtils', 'util/jqueryUtils'], function($, L, logger, Configuration, GeoUtils, StringUtils, JQueryUtils) {
function ServiceConfiguration(ws) {
var actionName = 'getConfiguration',
websocket = null;
......@@ -19,11 +19,24 @@ define(['jquery', 'leaflet', 'util/loggingUtils', 'isochrone/configuration', 'ut
this.sendRequest = function() {
websocket.sendWsMessage({
action: actionName
}, onServerResponse);
}, onServerResponse, onServerError);
};
// Private methods
/**
* @private
* @method ServiceConfiguration#onServerError
*/
function onServerError(e) {
var errorCls = 'AlgorithmException: ',
i = e.message.indexOf(errorCls);
if (e.httpState === 500) {
JQueryUtils.dialog(i > 0 ? e.message.substring(i + errorCls.length) : e.message);
}
}
/**
* Reads the enabled datasets and stores them in a client side configuration singleton
* each dataset contains:
......
/**
* @class ServiceDebugInfo
*/
define(['jquery', 'util/loggingUtils', 'util/languageUtils', 'jquery-ui-widgets/dialog'], function($, logger, LanguageUtils) {
define(['jquery', 'util/loggingUtils', 'util/languageUtils', 'util/jqueryUtils', 'jquery-ui-widgets/dialog'], function($, logger, LanguageUtils, JQueryUtils) {
function ServiceDebugInfo(ws) {
var actionName = 'getDebugInfo',
websocket = null;
......@@ -20,11 +20,24 @@ define(['jquery', 'util/loggingUtils', 'util/languageUtils', 'jquery-ui-widgets/
websocket.sendWsMessage({
action: actionName,
clearCache: true
}, onServerResponse);
}, onServerResponse, onServerError);
};
// Private methods
/**
* @private
* @method ServiceDebugInfo#onServerError
*/
function onServerError(e) {
var errorCls = 'AlgorithmException: ',
i = e.message.indexOf(errorCls);
if (e.httpState === 500) {
JQueryUtils.dialog(i > 0 ? e.message.substring(i + errorCls.length) : e.message);
}
}
/**
* @private
* @method ServiceDebugInfo#onServerResponse
......@@ -35,25 +48,8 @@ define(['jquery', 'util/loggingUtils', 'util/languageUtils', 'jquery-ui-widgets/
}
logger.debug('Successfully cleared cache... opening success message dialog');
$('#debug-dialog').dialog('close');
$('<div></div>').html(LanguageUtils.get('debug.successMessage')).dialog({
closeOnEscape: true,
dialogClass: 'dialog-no-close',
modal: true,
resizable: false,
title: LanguageUtils.get('debug.successTitle'),
buttons: [{
text: LanguageUtils.get('btn.ok'),
click: function() {
$(this).dialog('close');
}
}],
open: function() {
// focus first button (to prevent tooltip showing without hovering)
$(this).parent().find('button:eq(1)').focus();
}
});
JQueryUtils.dialog(LanguageUtils.get('debug.successMessage'), LanguageUtils.get('debug.successTitle'))
}
}
......
/**
* @class ServiceFeatureInfo
*/
define(['jquery', 'util/loggingUtils', 'isochrone/geoJsonStyle', 'util/languageUtils', 'util/stringUtils'], function($, logger, GeoJsonStyle, LanguageUtils, StringUtils) {
define(['jquery', 'util/loggingUtils', 'isochrone/geoJsonStyle', 'util/languageUtils', 'util/stringUtils', 'util/jqueryUtils'], function($, logger, GeoJsonStyle, LanguageUtils, StringUtils, JQueryUtils) {
function ServiceFeatureInfo(ws, targetContainer) {
var actionName = 'getFeatureInfo',
target = null,
......@@ -24,11 +24,24 @@ define(['jquery', 'util/loggingUtils', 'isochrone/geoJsonStyle', 'util/languageU
dataset: dataset,
direction: direction,
stopId: stopId
}, onServerResponse);
}, onServerResponse, onServerError);
};
// Private methods
/**
* @private
* @method ServiceFeatureInfo#onServerError
*/
function onServerError(e) {
var errorCls = 'AlgorithmException: ',
i = e.message.indexOf(errorCls);
if (e.httpState === 500) {
JQueryUtils.dialog(i > 0 ? e.message.substring(i + errorCls.length) : e.message);
}
}
/**
* @private
* @method ServiceFeatureInfo#onServerResponse
......
/**
* @class ServiceIsochrone
*/
define(['jquery', 'leaflet', 'util/loggingUtils', 'spin.js', 'isochrone/isochrone', 'isochrone/configuration', 'util/geoUtils'], function($, L, logger, Spinner, Isochrone, Configuration, GeoUtils) {
define(['jquery', 'leaflet', 'util/loggingUtils', 'spin.js', 'isochrone/isochrone', 'isochrone/configuration', 'util/geoUtils', 'util/jqueryUtils'], function($, L, logger, Spinner, Isochrone, Configuration, GeoUtils, JQueryUtils) {
function ServiceIsochrone(ws, iMap) {
var actionName = 'getIsochrone',
actionNameIncremental = 'incrementalIsochrone',
......@@ -89,7 +89,7 @@ define(['jquery', 'leaflet', 'util/loggingUtils', 'spin.js', 'isochrone/isochron
$(document).on(actionNameIncremental, incrementalEventHandler);
}
websocket.sendWsMessage(msg, successFn, stopSpinner);
websocket.sendWsMessage(msg, successFn, onServerError);
};
// Private methods
......@@ -106,6 +106,20 @@ define(['jquery', 'leaflet', 'util/loggingUtils', 'spin.js', 'isochrone/isochron
$('.dataset-limit-slider').slider(stateStr);
}
/**
* @private
* @method ServiceIsochrone#onServerError
*/
function onServerError(e) {
var errorCls = 'AlgorithmException: ',
i = e.message.indexOf(errorCls);
stopSpinner();
if (e.httpState === 500) {
JQueryUtils.dialog(i > 0 ? e.message.substring(i + errorCls.length) : e.message);
}
}
/**
* @private
* @method ServiceIsochrone#onServerResponse
......@@ -126,10 +140,6 @@ define(['jquery', 'leaflet', 'util/loggingUtils', 'spin.js', 'isochrone/isochron
incrementalEventHandler = null;
}
// TODO: Implement buffer/surface client method coverage (if coverage is not delivered by server):
// - using https://github.com/bjornharrtell/jsts or
// - using http://turfjs.org/
stopSpinner();
enableIsochroneElements(true);
if ((bBoxSize.x + bBoxSize.y) <= 0) {
......
/**
* @class JQueryUtils
*/
define(['jquery', 'util/languageUtils'], function($, LanguageUtils) {
/**
* @private
* @constructor
*/
function JQueryUtils() { }
/**
* @public
* @method JQueryUtils.alert
*/
JQueryUtils.dialog = function(outputMsg, titleMsg, onCloseCallback) {
var dialogId = 'jquery-isomap-dialog',
element = $('#' + dialogId);
if (!titleMsg) {
titleMsg = 'An error occurred';
}
if (!outputMsg) {
outputMsg = 'No message to display';
}
if (element.length <= 0) {
element = $('<div id="' + dialogId + '"></div>');
}
element.html(outputMsg).dialog({
closeOnEscape: true,
dialogClass: 'dialog-no-close',
modal: true,
resizable: false,
title: titleMsg,
buttons: [{
text: LanguageUtils.get('btn.ok'),
click: function() {
$(this).dialog('close');
}
}],
close: function() {
if (onCloseCallback) {
onCloseCallback();
}
/* Cleanup node(s) from DOM */
$(this).dialog('destroy').remove();
},
open: function() {
// focus first button (to prevent tooltip showing without hovering)
$(this).parent().find('button:eq(1)').focus();
}
});
}
return JQueryUtils;
});
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment