To give context to the part of RequestFactory I'm looking at, I've inserted the structure of the snippet below:
requestContext.persist().fire(new Receiver<ObjectProxy>(){
@Override
public void onSuccess(ObjectProxy response){
//Run code here...
}
@Override
public void onFailure(ServerFailure error){
//See the description below for what needs to be done here.
}
In the onFailure() function, I'd like to have different responses to the errors that may be thrown by Postgresql such as a violation of the uniqueness constraint when a user tries to insert a new barcode or new id number that has already been taken (the user must be able to choose the id).
This does not just have to be in the onFailure() function - I am looking for some place in the framework to do this handling.
You should take a look at GWT validation support and its example here https://developers.google.com/web-toolkit/doc/latest/DevGuideValidation
Validation groups can be used to specify what constraints to run on the client and what to run on the server.
The above feature is based on Java' JSR-303 Bean Validation.
Combine the Valiation feature with a simple remote logging feature of GWT and you have efficient clean way of handling exceptions - https://developers.google.com/web-toolkit/doc/latest/DevGuideLogging