Skip to content

Commit

Permalink
Handle errors when loading SampleBuffer's from within the constrcutor…
Browse files Browse the repository at this point in the history
… (for now)
  • Loading branch information
sakertooth committed Feb 16, 2025
1 parent d6cf026 commit 82ff2d3
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/core/SampleBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@

#include "SampleBuffer.h"

#include <QApplication>
#include <QMessageBox>
#include <QWidget>
#include <cstring>

#include "GuiApplication.h"
#include "MainWindow.h"
#include "PathUtil.h"
#include "SampleDecoder.h"

Expand All @@ -50,8 +55,12 @@ SampleBuffer::SampleBuffer(const std::filesystem::path& path)
return;
}

throw std::runtime_error{"Failed to decode audio file: The audio codec is possibly unsupported, the audio file "
"corrupted, or the path is invalid."};
// TODO: Move GUI error handling outside the core
if (gui::getGUI())
{
QMessageBox::critical(gui::getGUI()->mainWindow(), QObject::tr("Failed to load audio file"),
QObject::tr("The audio codec is possibly unsupported, the audio file corrupted, or the path is invalid."));
}
}

SampleBuffer::SampleBuffer(const std::string& base64, int sampleRate)
Expand Down

0 comments on commit 82ff2d3

Please sign in to comment.