3737#include " fatal.h"
3838#include < iostream>
3939#include < fstream>
40+ #include < sstream>
4041
4142#include " PresetFrameIO.hpp"
4243
44+ #include " PresetFactoryManager.hpp"
45+
46+
4347MilkdropPreset::MilkdropPreset (std::istream & in, const std::string & presetName, PresetOutputs & presetOutputs):
4448 Preset(presetName),
4549 builtinParams(_presetInputs, presetOutputs),
@@ -291,15 +295,7 @@ void MilkdropPreset::initialize(const std::string & pathname)
291295if (MILKDROP_PRESET_DEBUG)
292296 std::cerr << " [Preset] loading file \" " << pathname << " \" ..." << std::endl;
293297
294- if ((retval = loadPresetFile (pathname)) < 0 )
295- {
296- if (MILKDROP_PRESET_DEBUG)
297- std::cerr << " [Preset] failed to load file \" " <<
298- pathname << " \" !" << std::endl;
299-
300- // / @bug how should we handle this problem? a well define exception?
301- throw retval;
302- }
298+ loadPresetFile (pathname);
303299
304300 postloadInitialize ();
305301}
@@ -317,7 +313,7 @@ void MilkdropPreset::initialize(std::istream & in)
317313 std::cerr << " [Preset] failed to load from stream " << std::endl;
318314
319315 // / @bug how should we handle this problem? a well define exception?
320- throw retval ;
316+ throw PresetFactoryException ( " failed to read from input stream " ) ;
321317 }
322318
323319 postloadInitialize ();
@@ -530,9 +526,12 @@ int MilkdropPreset::loadPresetFile(const std::string & pathname)
530526 /* Open the file corresponding to pathname */
531527 std::ifstream fs (pathname.c_str ());
532528 if (!fs || fs.eof ()) {
533- if (MILKDROP_PRESET_DEBUG)
534- std::cerr << " loadPresetFile: loading of file \" " << pathname << " \" failed!\n " ;
535- return PROJECTM_ERROR;
529+
530+ std::ostringstream oss;
531+ oss << " Problem reading file from path: \" " << pathname << " \" " ;
532+
533+ throw PresetFactoryException (oss.str ());
534+
536535 }
537536
538537 return readIn (fs);
0 commit comments