Interception of a system error.

I have a code that contains the function "system.users [i] .name", but the problem is that sometimes "name" may be empty, and a system error occurs that I cannot catch.

Error text:

Script test_3 line 7: ERROR TypeError: system.users[i] has no properties in charater 1