Skip to content

Commit

Permalink
[Ref] openmpt123: Simplify error printing for audio backends.
Browse files Browse the repository at this point in the history
git-svn-id: https://source.openmpt.org/svn/openmpt/trunk/OpenMPT@21726 56274372-70c3-4bfc-bfc3-4c3a0b034d27
  • Loading branch information
manxorist committed Sep 23, 2024
1 parent c6534b3 commit d1ac8ac
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 29 deletions.
24 changes: 0 additions & 24 deletions openmpt123/openmpt123.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2371,30 +2371,6 @@ static mpt::uint8 main( std::vector<mpt::ustring> args ) {
std_err << MPT_USTRING("Error parsing command line.") << lf;
std_err.writeout();
return 1;
#ifdef MPT_WITH_ALLEGRO42
} catch ( allegro42_exception & e ) {
std_err << MPT_USTRING("Allegro-4.2 error: ") << mpt::get_exception_text<mpt::ustring>( e ) << lf;
std_err.writeout();
return 1;
#endif
#ifdef MPT_WITH_PULSEAUDIO
} catch ( pulseaudio_exception & e ) {
std_err << MPT_USTRING("PulseAudio error: ") << mpt::get_exception_text<mpt::ustring>( e ) << lf;
std_err.writeout();
return 1;
#endif
#ifdef MPT_WITH_PORTAUDIO
} catch ( portaudio_exception & e ) {
std_err << MPT_USTRING("PortAudio error: ") << mpt::get_exception_text<mpt::ustring>( e ) << lf;
std_err.writeout();
return 1;
#endif
#ifdef MPT_WITH_SDL2
} catch ( sdl2_exception & e ) {
std_err << MPT_USTRING("SDL2 error: ") << mpt::get_exception_text<mpt::ustring>( e ) << lf;
std_err.writeout();
return 1;
#endif
} catch ( silent_exit_exception & ) {
return 0;
} catch ( exception & e ) {
Expand Down
2 changes: 1 addition & 1 deletion openmpt123/openmpt123_allegro42.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct allegro42_exception : public exception {
}
}
allegro42_exception()
: exception( error_to_string() )
: exception( MPT_USTRING("Allegro-4.2: ") + error_to_string() )
{
}
};
Expand Down
2 changes: 1 addition & 1 deletion openmpt123/openmpt123_portaudio.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace openmpt123 {
inline constexpr auto portaudio_encoding = mpt::common_encoding::utf8;

struct portaudio_exception : public exception {
portaudio_exception( PaError code ) : exception( mpt::transcode<mpt::ustring>( portaudio_encoding, Pa_GetErrorText( code ) ) ) { }
portaudio_exception( PaError code ) : exception( MPT_USTRING("PortAudio: ") + mpt::transcode<mpt::ustring>( portaudio_encoding, Pa_GetErrorText( code ) ) ) { }
};

typedef void (*PaUtilLogCallback ) (const char *log);
Expand Down
2 changes: 1 addition & 1 deletion openmpt123/openmpt123_pulseaudio.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct pulseaudio_exception : public exception {
return mpt::ustring();
}
}
pulseaudio_exception( int error ) : exception( error_to_string( error ) ) { }
pulseaudio_exception( int error ) : exception( MPT_USTRING("PulseAudio: ") + error_to_string( error ) ) { }
};

class pulseaudio_stream_raii : public write_buffers_interface {
Expand Down
2 changes: 1 addition & 1 deletion openmpt123/openmpt123_sdl2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ struct sdl2_exception : public exception {
return s.str();
}
public:
sdl2_exception( int code, const char * error ) : exception( text_from_code( code ) + MPT_USTRING(" (") + mpt::transcode<mpt::ustring>( sdl2_encoding, error ? std::string(error) : std::string("NULL") ) + MPT_USTRING(")") ) { }
sdl2_exception( int code, const char * error ) : exception( MPT_USTRING("SDL2: ") + text_from_code( code ) + MPT_USTRING(" (") + mpt::transcode<mpt::ustring>( sdl2_encoding, error ? std::string(error) : std::string("NULL") ) + MPT_USTRING(")") ) { }
};

static void check_sdl2_error( int e ) {
Expand Down
2 changes: 1 addition & 1 deletion openmpt123/openmpt123_waveout.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
namespace openmpt123 {

struct waveout_exception : public exception {
waveout_exception() : exception( MPT_USTRING("waveout") ) { }
waveout_exception() : exception( MPT_USTRING("WaveOut: ") + MPT_USTRING("waveout") ) { }
};

class waveout_stream_raii : public write_buffers_interface {
Expand Down

0 comments on commit d1ac8ac

Please sign in to comment.