sanity check and exception handling in port value #80