fix type promotion for numeric types
add error locations
clean up exception handling