This is not going to work because you're in a separate thread. Vim could crash if you access vim internals from outside the GUI thread.

So it's commendable that you want to notify the user of the error, but it would do more harm then good. Remove the PostVimMessage call.