How to implement nonces so that undoing a trashed custom post type doesn’t cause an error?

How to implement nonces so that undoing a trashed custom post type doesn’t cause an error?