unless(open FILE, ">test.txt"){ #error handling code goes here }