PDA

View Full Version : Error Handling - execute request with extra argument



rapas
13 Mar 2014, 3:13 AM
Hi Guys,

Using bryntum ext scheduler, we want to implement some Error Handling logic. Within our application framework (server side) we for example distinguish errors, warnings and confirmation.
When for example a warning exception is thrown, the client should show the warning, and when the user aggrees on continuing, the request should be executed again with an extra argument, so that the server knows that the request is aknowledged and can be executed again ignoring the warning.

In the EventStore proxy we added an afterRequest function that checks if the response was successfull (contains an exception). If so, the exception message will be shown.
Is it possible for us to re-execute the request with some changes in the arguments.

Below the function that is called in the afterRequest function.:


// this function will handle response exceptions when the request was not successfull.
function requestMessageProcessor(proxy, response) {
if (response && proxy) {
try {
var responseData = proxy.reader.getResponseData(response);
var errorData = Ext.decode(response.responseText);

if (errorData.error && errorData.error.message) {
var messageDescription = 'Information'; // title of the alert box
var messageIcon = Ext.MessageBox.INFO;

// TODO: determine the type of message


if (!errorData.success)
{
var messageDescription = 'Error';
var messageIcon = Ext.MessageBox.ERROR;
}

Ext.MessageBox.show({
title: messageDescription,
msg: errorData.error.message,
buttons: Ext.MessageBox.OK,
icon: messageIcon
});
// TODO: if warning/confirmation acknowledged, we have to repeat the request
// with some additional/changed argument
}
}
catch(err) {
// Malformed response most likely
console.log(err);
}
}
}

Gary Schlosberg
18 Mar 2014, 9:14 AM
I haven't used Ext Scheduler myself, but if no one is able to offer assistance here you might also try posting your question on the Bryntum forum.