From 6e1b2af7703da023ec2fe7d27b03a58fa127bcb2 Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Thu, 7 May 2020 16:02:28 -0400 Subject: [PATCH] Descriptive error message when using AudioStream(OGG/MP3) incorrectly (cherry picked from commit 193564d83e3d248ea35284beed36ff653919256d) --- modules/minimp3/audio_stream_mp3.cpp | 5 ++++- modules/stb_vorbis/audio_stream_ogg_vorbis.cpp | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/minimp3/audio_stream_mp3.cpp b/modules/minimp3/audio_stream_mp3.cpp index bea2dc112c6..a73381ae578 100644 --- a/modules/minimp3/audio_stream_mp3.cpp +++ b/modules/minimp3/audio_stream_mp3.cpp @@ -120,7 +120,10 @@ AudioStreamPlaybackMP3::~AudioStreamPlaybackMP3() { Ref AudioStreamMP3::instance_playback() { Ref mp3s; - ERR_FAIL_COND_V(data == nullptr, mp3s); + ERR_FAIL_COND_V_MSG(data == nullptr, mp3s, + "This AudioStreamMP3 does not have an audio file assigned " + "to it. AudioStreamMP3 should not be created from the " + "inspector or with `.new()`. Instead, load an audio file."); mp3s.instance(); mp3s->mp3_stream = Ref(this); diff --git a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp index 99ac985d6f3..783a1a45d66 100644 --- a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp +++ b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp @@ -130,7 +130,10 @@ Ref AudioStreamOGGVorbis::instance_playback() { Ref ovs; - ERR_FAIL_COND_V(data == NULL, ovs); + ERR_FAIL_COND_V_MSG(data == NULL, ovs, + "This AudioStreamOGGVorbis does not have an audio file assigned " + "to it. AudioStreamOGGVorbis should not be created from the " + "inspector or with `.new()`. Instead, load an audio file."); ovs.instance(); ovs->vorbis_stream = Ref(this);