Skip to content

Commit 3c895e2

Browse files
using throw and not exit()
1 parent 9feb59f commit 3c895e2

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

app/audioRewrapper/audioRewrapper.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ void transcodeAudio( const char* inputfilename, const char* outputFilename )
7474

7575
if( ! outputStreamAudio.setup( ) )
7676
{
77-
std::cout << "error during initialising audio output stream" << std::endl;
78-
exit( -1 );
77+
throw std::runtime_error( "error during initialising audio output stream" );
7978
}
8079

8180
// Transcoding

app/avTranscoder/avTranscoder.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ void transcodeVideo( const char* inputfilename, const char* outputFilename )
7070

7171
if( !outputStreamVideo.setup( ) )
7272
{
73-
std::cout << "error during initialising video output stream" << std::endl;
74-
exit( -1 );
73+
throw std::runtime_error( "error during initialising video output stream" );
7574
}
7675

7776
Image imageToEncode( sourceImage );
@@ -88,8 +87,7 @@ void transcodeVideo( const char* inputfilename, const char* outputFilename )
8887

8988
if( ! of.setup( ) )
9089
{
91-
std::cout << "error during setup output file" << std::endl;
92-
exit( -1 );
90+
throw std::runtime_error( "error during setup output file" );
9391
}
9492

9593
of.addVideoStream( inputFile.getStream( 0 ).getVideoDesc() );
@@ -145,8 +143,16 @@ int main( int argc, char** argv )
145143

146144
std::cout << "start ..." << std::endl;
147145

148-
// example of video Transcoding
149-
transcodeVideo( argv[1], "transcodedVideo.avi" );
146+
try
147+
{
148+
// example of video Transcoding
149+
transcodeVideo( argv[1], "transcodedVideo.avi" );
150+
}
151+
catch( std::exception &e )
152+
{
153+
std::cout << "[ERROR] " << e.what() << std::endl;
154+
}
155+
150156

151157
std::cout << "end ..." << std::endl;
152158
}

0 commit comments

Comments
 (0)