Throw an exception in ScopedCallback for invalid callbacks.

Change-Id: I303dec64e55df0b1de73c6db6577bfb005cbe464