Hello,

Actually, i m working on Reactive Web App. So, i have created one form also i have set the index like there must be unique value in the list of items so for that i have created index. Now, when i m performing like entering duplicate value in form and submitting, it shows me System generated exception. Its fine like what i have done its working properly but the only thing i want to know instead of that system generated exception i want that it shows that message in exception which i want, it should display. Kindly, do let me know how should i perform this thing. This gonna be helpful for me. Also, i m attaching a file regarding the exception occurs , which give you more clarity. Will wait for your kind revert.

Hi Rohit,

The message you are seeing is the message generated by database directly, that is configured in the Database Exception raised when you try to create your second (and duplicate) record.

If you want to customize it, you will have to handle that exception (typically in the same server action flow where you have your CreateYourEntity entity action) and raise your own exception with the message you want.

Alternatively, you can add an exception handler for Database Exception to the Screen Action (or Client Action) that calls the entity action and use a Message tool to display a popup message with your content:

Hope this helps!

Jorge Martins wrote:

Hi Rohit,

The message you are seeing is the message generated by database directly, that is configured in the Database Exception raised when you try to create your second (and duplicate) record.

If you want to customize it, you will have to handle that exception (typically in the same server action flow where you have your CreateYourEntity entity action) and raise your own exception with the message you want.

Alternatively, you can add an exception handler for Database Exception to the Screen Action (or Client Action) that calls the entity action and use a Message tool to display a popup message with your content:

Hope this helps!

 

 Hello Jorge,

Thanks for your valuable advice!!! I tried what you have explained me in earlier message. 

But still i m getting the same thing as i was getting earlier.

Still i m unable to sort out this thing. Could you please guide what else can be done to sort this out. It will be very helpful for me. will wait for your kind revert.

Best Regards.

Rohit,

Can you debug your application to pinpoint where this exception is being raised? It seems like what you did would avoid the ugly database message when you call the OnSaveClick screen action... Is there any other place where you might be creating a new record?

Hi Rohit,

@Jorge is right also see below post for same question

https://www.outsystems.com/forums/discussion/62586/replace-messages/


Regards

Rahul Sahu

Hi Rohit,

Your screenshot shows that you did NOT exactly do what Jorge told you. Check of the exception handler from Jorge and yours:


The one from Jorge will sent a user friendly error message

Yours is just raising another exception, there for you still don't get a user friendly exception

Regards,

Daniel

Rohit,

Only after Daniel's post didI notice that difference.

You can do exactly like I showed, or you can simply provide a meaningful message in the DuplicateValueException, instead of using the one that came from DatabaseException... should work too.

Hi guys,

there are a lot of bugs/hidden features in the exception handling, with differences between for example reactive and traditional.  

I have done some tests for this example, and find that it is not possible to handle a database exception in client action of a reactive app, I think the information that it is a database exception gets lost between server and client side. It is possible to handle the database exception in the action where it is raised, or in a calling server action, but not in the calling client action or in the OnException global handler.

So only the first solution of Jorge works, the second doesn't, it will be handled by the AllExceptions handler, not the DatabaseException handler.


On a different note, this might be an ok approach for simple cases where the database exception can only be one specific thing, but I don't think that holds up in the real world, there can be several indexes, there can be wrong foreign keys, there can be values of wrong format or length,...  So all of them will be translated into some 'duplicate' custom message, hiding what is really going on.

I think the only good way of dealing with this is to do upfront validations.  In this case for example, first check if there is already a record with that value, and if so, set a user friendly message.

Dorine 

see attached oml with some tests of reactive exception handling.

Hi Dorine,

You are right. Thank you for the detailed explanation. Reactive was based on mobile, where these issues were probably already there but developers started working around them. We already have other ideas regarding exceptions, namely being able to make user exceptions public, and making the OnException action also public. If we can't fix the issues you have described sooner (problems that impact running applications without workarounds usually take precedence), we'll probably tackle them when addressing any of these ideas.

Your module will really help in this.

Thanks a lot,
Tiago Simões

Hi Tiago,

good to hear that there are plans to improve on exceptions.  

Just out of curiosity, is there any plan to add the capability of giving an exception a standard message.  I find that when raising an exception, I often don't want to add any context information, and seem te be forever having to give it the same message text.  It would be nice if exceptions come with a standard exception text, which is used if you don't override at time of raise exception.  This would also improve consistency, same exception is displayed with same text, no matter where (and by what developr) it was raised.

Also, to be complete, I'm attaching a similar testing module I once made for tradional, with it's own flaws...

oh, and the ability to rethrow them would also be brilliant  :-)

Thanks. Those are two other great ideas. Please add them here https://www.outsystems.com/ideas/ so we can find them when we address exceptions. Just to be transparent, we do not have short term plans to tackle this (i.e. this year), but given that exceptions rank highly on ideas I'm hopeful we can address them as a whole in the not so distant future.