Catch exceptions in toString and display 'undefined'