changeset 1273:132706e3b94b

Improve error handling and reporting slightly.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 03 Oct 2016 09:06:01 +0300
parents acae5f8ebc67
children 1b1e7c771698
files src/dmlib.c src/dmlib.h src/dmpack.c src/dmsimple.c
diffstat 4 files changed, 12 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/dmlib.c	Thu May 19 12:08:16 2016 +0300
+++ b/src/dmlib.c	Mon Oct 03 09:06:01 2016 +0300
@@ -187,8 +187,10 @@
 
         case DMERR_DATA_ERROR:     return "Data decoding/encoding/parsing error";
 
+        case DMERR_VERSION:        return "Unsupported file format version";
+
         case DMERR_NOTPACK:        return "File is not a PACK";
-        case DMERR_VERSION:        return "Unsupported PACK version";
+        case DMERR_PACK_VERSION:   return "Unsupported PACK version";
         case DMERR_INVALID:        return "Invalid data, corrupted file";
         case DMERR_COMPRESSION:    return "Error in compression";
 
--- a/src/dmlib.h	Thu May 19 12:08:16 2016 +0300
+++ b/src/dmlib.h	Mon Oct 03 09:06:01 2016 +0300
@@ -112,10 +112,12 @@
     DMERR_BOUNDS,
 
     DMERR_DATA_ERROR,   // Data decoding/encoding/parsing error
+    
+    DMERR_VERSION,      // Unsupported data version
 
     // PACK-file subsystem
     DMERR_NOTPACK,
-    DMERR_VERSION,
+    DMERR_PACK_VERSION,
     DMERR_INVALID,
     DMERR_COMPRESSION,
 };
--- a/src/dmpack.c	Thu May 19 12:08:16 2016 +0300
+++ b/src/dmpack.c	Mon Oct 03 09:06:01 2016 +0300
@@ -123,7 +123,7 @@
 
     if (hdr.version != DPACK_VERSION)
     {
-        ret = DMERR_VERSION;
+        ret = DMERR_PACK_VERSION;
         goto out;
     }
 
--- a/src/dmsimple.c	Thu May 19 12:08:16 2016 +0300
+++ b/src/dmsimple.c	Mon Oct 03 09:06:01 2016 +0300
@@ -735,7 +735,7 @@
 
     if ((err = engineInitAudioParts(&engine)) != DMERR_OK)
     {
-        dmErrorDBGMsg(
+        dmErrorMsg(
             "engineInitAudioParts() failed: #%d: %s\n",
             err, dmErrorStr(err));
         goto out;
@@ -745,7 +745,7 @@
     if (engine.demoInitPreVideo != NULL &&
        (err = engine.demoInitPreVideo(&engine)) != DMERR_OK)
     {
-        dmErrorDBGMsg(
+        dmErrorMsg(
             "demoInitPreVideo() failed, #%d: %s\n",
             err, dmErrorStr(err));
         goto out;
@@ -770,7 +770,7 @@
     dmPrint(1, "Loading resources, please wait...\n");
     if ((err = engineLoadResources()) != DMERR_OK)
     {
-        dmErrorDBGMsg(
+        dmErrorMsg(
             "Error loading resources, #%d: %s.\n",
             err, dmErrorStr(err));
         goto out;
@@ -780,7 +780,7 @@
     dmPrint(1, "Initializing demo...\n");
     if ((err = engine.demoInit(&engine)) != DMERR_OK)
     {
-        dmErrorDBGMsg(
+        dmErrorMsg(
             "Failure in demoInit(), #%d: %s\n",
             err, dmErrorStr(err));
         goto out;
@@ -789,7 +789,7 @@
     // Initialize effects
     if ((err = engineInitializeEffects(&engine)) != DMERR_OK)
     {
-        dmErrorDBGMsg(
+        dmErrorMsg(
             "Effects initialization failed, #%d: %s\n",
             err, dmErrorStr(err));
         goto out;