6.0 Building trees and handling exceptions

(Mac version)

< 5.0 | 6.0 | 6.1 >

In this step you will learn how to build a tree in memory from a Newick tree description and will create an exception class (XStrom) to handle unexpected run-time circumstances.

The previous section added the function makeNewick that saves a tree in memory to a string in newick format. This part will focus on the opposite: building a tree in memory given a newick string. After finishing this part, you will be in position to read trees from a tree file and build each one in computer memory.

Sometimes programs encounter situations that were unexpected. For example, the user supplies a data file name, but that file does not contain data, or contains data in a format that the program is not prepared to handle. In these circumstances, our program should exit with an informative message for the user so that they know what to correct before running it again. This is accomplished by throwing an exception, which is an object (an instance of the XStrom class). The main function will catch any exception thrown at any point and display the message carried by the XStrom object to the user before exiting.

Step Title Description
Step 6.1 Build a tree from a newick description

This section will focus on creating the function buildFromNewick

Step 6.2 The XStrom exception class

In this section you will create a class to handle exceptions

Step 6.3 Test building trees

In this section you test buildFromNewick function and will see how to handle run-time exceptions

< 5.0 | 6.0 | 6.1 >