run afterException using `db`