I think an internal flag would be better here.

With multiple libraries attaching to window.onerror, this can end up badly.
Do you mind adding a flag? Like- _isOnerrorHandlerInstalled?