The run() method clears the log window and evaluates the script using the method that we learned earlier in this chapter. If the evaluation is successful, it prints the result in the log window, which is what we see in the first screenshot shown in the previous section.
In the second attempt, we made an error in the script using a nonexistent variable. Evaluating such code results in an exception. In addition to reporting the actual error, we also use the lineNumber property of the returned Error object to report the line that caused the problem. Next, we display the stack property of the error object, which returns the backtrace (a stack of function calls) of the problem, which we also print on the log.