Fix invalid call of the Exception construct method

The Exception is sometimes called without the second parameter. This
trigger warnings in PHP. I change the second parameter to optional. The
check if the $object is a object is already in the code.