<?php
class IsNullException extends Exception { }
class IsEmptyException extends Exception { }
function throwWhenNullOrEmpty($list)
{
if (is_null($list)) {
throw new IsNullException();
}
if (count($list) == 0) {
throw new IsEmptyException();
}
}
try {
throwWhenNullOrEmpty(null);
}
catch (Exception $e) {
echo "Error happened";
}