fixed crash on macosx when pasting non text stuff in a string

added an error handler