Better handling of errors when discarding changes