I develop a Top Page screen with a Advanced SQL on Preparation. In Preparation, I using DatabaseException to catch and handling Exception. The code will use DatabaseException.ExceptionMessage value to decide next action. Example:
+ If the ExceptionMessage contains "fatal error" then show a message "Have fatal error" to user
+ If the ExceptionMessage contains "can't find record" then throw a UserException to redirect to Internal Error screen
+...
But, i have a problem that most of DatabaseException.ExceptionMessage is short message "Error executing query. " while on Service Center, it is is full message as "Error executing query. Error in advanced query...".
=> How to get full message with DatabaseException.ExceptionMessage as on Service Center? Anyone for help?
Hello Cuong,
All these logs can be checked on the Log tables views that can be accessed through the PlatformLogs extension.
You have some documentation about the logs here:
https://success.outsystems.com/documentation/11/managing_the_applications_lifecycle/monitor_and_troubleshoot/logging_database_and_architecture/log_data_reference/
https://success.outsystems.com/documentation/11/managing_the_applications_lifecycle/monitor_and_troubleshoot/logging_database_and_architecture/the_log_tables_and_views/
Please check if this helps you, otherwise, we can dig a bit deeper to help you.
Regards,
PZ
Thanks Paulo Zacarias!
✧ "All these logs can be checked on the Log tables views that can be accessed through the PlatformLogs extension. " => I know that but there is a problem when using Log_Error table
✧ My code when a DatabaseException is raised
- Step 1: Using a SQL to get newest error log from Log_Error where username = 'OutSystem logined username' and Espace_Name = 'MyApplication'
- Step 2: Get Message value from the record return by Step 1 and using it to check:
✧ Problem of my code above:
When DatabaseException is raised then the error log will be inserted to Log_Error table asynchronously
=> Sometime the sql using in Step 1 run before the error log completes insert to Log_Error
=> It gettting wrong error log => Bug occurred
Is there any way to setting to DatabaseException.ExceptionMessage is full message as the message display on Service Center? Example: Custom Code DatabaseException, setting on OutSystems Service Center,...
Hi Cuong,
Yes, the log is done asynchronously and that can occur as you already experienced.
I don't think there's a way to get the full log message when the exception is raised and captured on the Service Studio.
In this case, I don't see a solution other than displaying the message with only what is retrieved from the handler, concatenated with some additional info like some kind of instructions on how to check the full log.
Hi Paulo Zacarias,
It's a pity that no other solution could be found
Thanks you very much for your support!
Hi, i wanna put my input here this is my opinion, but it seems to me that Preparation is not intended to create complex logic in it.
In Preparation you can fetch data and do something with it. In Traditional Web Apps, the Preparation is a server-side Action that fetches the Screen data and prepares it for showing on the Screen.
Can you do that exception validation decide next action after ?
Hi Caldeira81,
"but it seems to me that Preparation is not intended to create complex logic in it. " => No, it isn't complex logic. I only want to exception validation decide next action after. Example:
+ If it is sql query error (DatabaseException) with message "...fatal error..." then show a message to user
+ If it is sql query error (DatabaseException) with message "...can't find record..." then show another message to user
But my problem that can't implement above logic because when DatabaseException raised, DatabaseException.ExceptionMessage always "Error executing query. "
Hi @Cuong Cao ,
I'm with @Caldeira81 on this one.
Getting errors executing queries is a sign that your code is not well developed or robust for edge cases. Once it is stable and well tested, this should not happen normally, and so when it does, it is ok to have to go look in Service Center logs for the troubleshooting.
It sounds odd to me that you would do any handling in your flow of this, it is always bad when it happens. A.f.a.i.k., there will never be an exception just for not finding any record, like you were suggesting. Can you show more about where exactly you are encountering this problem and what your sql looks like ?
Dorine
Hi Dorine Boudry,
My web consists of 2 parts:
+ Part 1: A Google App Engine batch using to get data from Big Query, handle data and save to DB (Example: Table A)
+ Part 2: OutSystems traditional web getting data from DB and showing on the Screen.
My problem that sometime user access to my OutSystems web at batch is running then i getting a sql error with message "...can't find record in table..". Currently I can't fix this error so my solution is:
+ If a DatabaseException raised with DatabaseException.ExceptionMessage contains "can't find record in table" then show a message as "Batch is running, please waiting 15 minutes and access again"
+ Otherwise, redirect to Internal Error screen
think about (re)designing your application in such a way that you don't have to rely on picking apart database errors to know what to do.
For example, when your Part1 is running, set som flag or status field so the Part 2 screen knows it is not a good time to retrieve data and give user a message to wait. Or make your query more robust that it doesn't abend, but returns nothing during Part 1.
Whether or not a database error occurs, the data retrieved while Part1 is updating is probably not reliable, so better to show nothing, even if it would technically not fail.
But really, a database exception only when a record is not found ?? can you show the sql and the error ?
Hi @Dorine Boudry ,
Thank for your support!
- "But really, a database exception only when a record is not found ?? ". I don't know: why "...a record is not found..." exception occurred. DB should be return 0 record if a table is empty. Do you know what causes this error to appear? (I use MySql DB)
- "Can you show the sql and the error ? " => For security reasons of my company this is not possible
Aah OK,
you are talking about an external database, then ??? Does that mean that this whole "Step A" happens outside of Outsystems ?
I haven't worked with (MySql) external db in Outsystems setting, so don't know how error handling and such works, and what other type of errors you can get back from MySql compared to regular Outsystems entities.
But again, whatever you make, think in terms of making things robust / checking availability of data upfront, rather than having to puzzle from some error message after the fact, what exactly is going on.
Since you can't share more details, there's not much more I can think of