According to Mozilla Website, The TypeError object represents an error when an operation could not be performed, typically (but not exclusively) when a value is not of the expected type.
A TypeError may be thrown when:
an operand or argument passed to a function is incompatible with the type expected by that operator or function; or
when attempting to modify a value that cannot be changed; or
when attempting to use a value in an inappropriate way.
You can use a try-catch segment to catch the TypeError. Also, if you are using TAU library, then I would suggest you to check the same code on a BasicUI project.