I chose to do it this way to mimic the previous behavior. Previously the error message was indeed displayed by addLayerToMap when the doAlert argument was true. If addPreviewLayer displays the error message then the error message will be displayed on mouseover, which doesn't sound good.