The error messages are displayed when a http call from the user interface returns an error code. So it is only used in direct user interaction. Custom plugins are usually task plugins that are run in a different context; not directly triggered by a UI request. In that case it is not possible to generate an error popup. There is no event queue for that. the only case where it would work would be in a custom tile UI.