Hi All ,
What is the best way to handle error messages thrown from SQL queries in a server action?
Regards,
Ishmael
Hi Thizwilondi,
Use the DatabaseException to capture an exception occurred in the query. You just need to drag the ExceptionHandler from the left pane, and select the DatabaseException type.
As shown on the message, you will have access to the database exception message with DatabaseException.ExceptionMessage, and you can set up your own logic to deal with it.
You can read more in OutSystems documentation about handling exceptions, and database exceptions in particular.
Kind Regards,João
Hi João,
Thank you for the respond , does that database exception encapsulate the message to avoid giving much information about the tables ? Given that I do not give it a custom error message.
That's the part of handling it :)
If you just want to avoid disclaiming your internal tables (which is a good practice by the way), you can raise an exception with your custom message, like on the image below:
Cheers,João
Alright great thank you!