Handle db exception