How can you extend PHP's RuntimeException class so you don't have to throw RuntimeException for every runtime exception?
1 Answer
Extending PHP's RuntimeException class is easy, as you don't have to implement any methods. For example, see this sample program:
class DomHtmlLoadException extends RuntimeException {}
throw new DomHtmlLoadException("cannot load /tmp/lockss-manifest.html");
echo "done BUT NO EXCEPTION!.\n";
Running this sample program yields a DomHtmlLoadException with the message "cannot load /tmp/lockss-manifest.html".