1

How can you extend PHP's RuntimeException class so you don't have to throw RuntimeException for every runtime exception?

1 Answer 1

1

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".

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.