ErrorHandler function

Handling errors