I am querying a database in R using RJDBC. The queries are built up from data which is read in from a file. These queries can get very long, and can potentially include non existent columns (resulting in an error).
Below is a simplified example, it takes the file as input and the runs 2 queries generated from the file.
table column drinks cost drinks sugar drinks volume food cost
SELECT column, cost, sugar FROM drinks;
SELECT cost FROM food;
Because these queries can get very long, any errors from the database are often truncated before the useful information. One of my current errors reads:
ERROR [2018-05-16 16:53:07] Error processing table data_baseline_biosamples for DAR-2018-00008 original error message: Error in .verify.JDBC.result(r, "Unable to retrieve JDBC result set for ", : Unable to retrieve JDBC result set for SELECT ed.studyid, {very long list of columns} ,ct.nmr_xl_vldl_pl,ct.nmr_xl_
Because the database error includes the entire query before the key information, the truncation removes valuable information for solving the problem.
In this case the error message probably ends with something like this:
(line 1, Table 'data_biosamples' owned by 'littlefeltfangs' does not contain column 'sample_source'.)
How to I record the full error message sent by the database or otherwise extract the final part of that message?
I am capturing the error in a tryCatch and passing the error into a log file using futile.logger. The total error length when truncated is 8219 characters, with 8190 of those appearing to be from the database.