added function to print function errors