|
@@ -104,7 +104,6 @@ int parseColor( std::string arg, float* r, float* g, float* b, float* a ) {
|
104
|
104
|
*a = 1;
|
105
|
105
|
int num = sscanf( copy.c_str(), "%f %f %f %f", r, g, b, a );
|
106
|
106
|
if ( num != 3 && num != 4 ) {
|
107
|
|
- fprintf( stderr, "Error parsing color %s\n", arg.c_str() );
|
108
|
107
|
return EXIT_FAILURE;
|
109
|
108
|
}
|
110
|
109
|
return EXIT_SUCCESS;
|
|
@@ -178,8 +177,17 @@ int app( int argc, char** argv ) {
|
178
|
177
|
int borderSize = options.bordersize_arg;
|
179
|
178
|
int tolerance = options.tolerance_arg;
|
180
|
179
|
float r, g, b, a;
|
181
|
|
- parseColor( options.color_arg, &r, &g, &b, &a );
|
182
|
|
- float gracetime = atof( options.gracetime_arg );
|
|
180
|
+ err = parseColor( options.color_arg, &r, &g, &b, &a );
|
|
181
|
+ if ( err != EXIT_SUCCESS ) {
|
|
182
|
+ fprintf( stderr, "Error parsing color %s\n", options.color_arg );
|
|
183
|
+ return EXIT_FAILURE;
|
|
184
|
+ }
|
|
185
|
+ float gracetime;
|
|
186
|
+ err = sscanf( options.gracetime_arg, "%f", &gracetime );
|
|
187
|
+ if ( err != 1 ) {
|
|
188
|
+ fprintf( stderr, "Error parsing %s as a float for gracetime!\n", options.gracetime_arg );
|
|
189
|
+ return EXIT_FAILURE;
|
|
190
|
+ }
|
183
|
191
|
bool highlight = options.highlight_flag;
|
184
|
192
|
bool keyboard = !options.nokeyboard_flag;
|
185
|
193
|
bool decorations = !options.nodecorations_flag;
|
|
@@ -376,12 +384,16 @@ int app( int argc, char** argv ) {
|
376
|
384
|
}
|
377
|
385
|
|
378
|
386
|
int main( int argc, char** argv ) {
|
379
|
|
- int exitvalue = EXIT_SUCCESS;
|
380
|
387
|
try {
|
381
|
|
- exitvalue = app( argc, argv );
|
382
|
|
- } catch( std::exception* exception ) {
|
383
|
|
- fprintf( stderr, "Unhandled Exception Thrown: %s\n", exception->what() );
|
384
|
|
- exit( EXIT_FAILURE );
|
|
388
|
+ return app( argc, argv );
|
|
389
|
+ } catch( std::bad_alloc const& exception ) {
|
|
390
|
+ fprintf( stderr, "Couldn't allocate enough memory! No space left in RAM." );
|
|
391
|
+ return EXIT_FAILURE;
|
|
392
|
+ } catch( std::exception const& exception ) {
|
|
393
|
+ fprintf( stderr, "Unhandled Exception Thrown: %s\n", exception.what() );
|
|
394
|
+ return EXIT_FAILURE;
|
|
395
|
+ } catch( ... ) {
|
|
396
|
+ fprintf( stderr, "Unknown Exception Thrown!\n" );
|
|
397
|
+ return EXIT_FAILURE;
|
385
|
398
|
}
|
386
|
|
- return exitvalue;
|
387
|
399
|
}
|