Proper error handling to allow error message to show when view file