capturing exceptions from mysql