move error responce check into exception handler in 'with_connection'