refactor(client): Extract common code in displayError and displayErrorUnsafe, pass in a write strategy.

fixes #1402