Add code to extract data from exception thrown

Quickly merging to ensure data grabbed is correct before messing with the sql at all