Write Awesome User Manuals and Tutorials for Software Products
Wednesday, February 14, 2007
Custom Exceptions
Till now we have seen why we need Exceptions and how to manage code that could throw Exceptions. We still have not learned how to throw our own Exceptions. Let us first understand the code below.
01public class DocToPdfConverter { 02public void convert(String src, String des) { 03Document doc = readDoc(src); 04writePdf(doc, des); 05} 06 07private Document readDoc(String srcPath) { 08//read the source file and verify format 09//if format is incorrect then throw an Exception 10} 11 12private void writePdf(Document doc, String des) { 13//convert the document into pdf 14} 15}
No comments:
Post a Comment