How to code error handling for notesstream.writetext

How to code the error handling mechanism for notesstream.writetext.