catch TypeErrors and differentiate between cat and decrypt/encrypt modes