Throw an exception instead of PHP fatal error