websocket: replace panic calls with errors.