Fix crash when throwing an exception from within a constructor

We need to check for the exception before doing anything with the returned
value.

Change-Id: I0086be96b2df2434b95187489d7430ae67f561a1
Reviewed-by: Lars Knoll <lars.knoll@digia.com>