Error handling in functions

shape