Refactor media player error handling