Error checking when running functions and expressions