#1: added type information
#2: made an error message more informative