Allow specifying an exception to raise

Make it easy to specify an exception that should be raised instead of
having to create a callback and raise it manually.

Change-Id: Iabf951e070e9ba8572f5ac14f4e09dbdd5824261
Closes-Bug: #1402496
Merge "Allow specifying an exception to raise"