improved error messages when IMG_Load() fails loading an image
authorHolger Schemel <info@artsoft.org>
Tue, 10 Dec 2019 22:52:33 +0000 (23:52 +0100)
committerHolger Schemel <info@artsoft.org>
Tue, 10 Dec 2019 22:52:33 +0000 (23:52 +0100)
If loading an image using "IMG_Load()" fails, the name of the file is
now also displayed with the error message.

This already worked in the past, but was broken since commit a2698b3b.

src/libgame/sdl.c

index 1184acd84a4b227af94424e920b8b201bdb42344..7fb650f1b17e9d6070db72855db59cf9c5e34c61 100644 (file)
@@ -273,7 +273,7 @@ static void SDLSetWindowIcon(char *basename)
 
   if ((surface = IMG_Load(filename)) == NULL)
   {
-    Error(ERR_WARN, "IMG_Load() failed: %s", SDL_GetError());
+    Error(ERR_WARN, "IMG_Load('%s') failed: %s", basename, SDL_GetError());
 
     return;
   }
@@ -2239,7 +2239,8 @@ Bitmap *SDLLoadImage(char *filename)
 
   // load image to temporary surface
   if ((sdl_image_tmp = IMG_Load(filename)) == NULL)
-    Error(ERR_EXIT, "IMG_Load() failed: %s", SDL_GetError());
+    Error(ERR_EXIT, "IMG_Load('%s') failed: %s", getBaseNamePtr(filename),
+         SDL_GetError());
 
   print_timestamp_time("IMG_Load");