Skip to content
Advertisement

How to close program if text document is not found

This is the top of my program. You are to type in a .txt file name for it to open.

Problem: How do I have the program display an error message and close the program if .txt file is not found?

JavaScript

Advertisement

Answer

You can put File in try catch block like this and show a relevant message:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement