Users are not getting informed on error saving record

Our backend database is MS SQL server 2000.
I have a form that on open calls for

databaseManager.setAutoSave(false);

In this form I have a button called Save

var message = ""; 
message += 'Do you want to save the change?\n' 
var thePressedButton =  plugins.dialogs.showInfoDialog( 'Result',  message,  'OK', 'No') 
if (thePressedButton != 'OK') 
{ 
   databaseManager.rollbackEditedRecords() 
	controller.loadOmittedRecords();
    return; 
} 
else if (thePressedButton == 'OK') 
{ 
	databaseManager.saveData()
   	message += 'Record saved.\n'; 
	controller.loadOmittedRecords();
}

When users call the above Save method.
If there is any error from backend such as duplicated record or not matching the table criteria, Servoy client does not inform the users about any error from backend database and then Servoy client hangs.
Is there any way at least to let users know that there was some error with backend or something that informs users that there is an error instead of doing nothing.

Thanks in advance for any help.

Abrahim

There are ways to trap an error.

You can use try{}catch{}finally{} and there are, in 3.5 a couple of error messages availabel ‘out of the box’…

Marcel,

I was able to create a method:

var message = ""; 
databaseManager.saveData();
//Get the failed records after a save
var array = databaseManager.getFailedRecords()
for( var i = 0 ; i < array.length ; i++ )
{
	var record = array[i];
	var alert = application.output(record.exception);
//message += '+ array[i] +'
plugins.dialogs.showErrorDialog( "Error", "Error saving redord", 'OK'); 

}

In servoy Debuger output I see:

com.servoy.j2db.dataprocessing.DataException: Violation of PRIMARY KEY constraint 'PK_IMG_Excel'. Cannot insert duplicate key in object 'IMG_Excel'.

I triyed to show the debuger output to the client screen via plugins.dialogs.showErrorDialog, but no success.

Is there a way to show the debugger out put to the client screen?
Am I going to the right path here or there is another way of doing this?

Thanks in advance,

Abrahim

Is there a way to show the debugger out put to the client screen?

Not in another way than you already try.

The try {} catch {} is another way, pretty good documented all over the internet ( or in my post ServoyWorld class :) )

If it works in “Autosave mode” but not when autosave is set to off,
then I have had the same kind of problem.

I use the Onerror method on the solution level.

The error is catched in “autosave” mode, but not when autosave
is off.

I created a case for this (83245)

Thanks,

Abrahim