Catch database error in test command handler instead of crashing