Added check for not null, made error be an exception. Made error message be clearer.
Removed unused var.
Merge branch 'progressCallback' into quantum

* progressCallback:
  Removed unused var.
  Added check for not null, made error be an exception. Made error message be clearer.
Casting to avoid compiler warning.