changeset 265:05bbe428a0ab

Unify SIDLib error messages.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 06 Jan 2020 00:05:16 +0200
parents 5afa6052f796
children 254828e9213b
files sidlib.c
diffstat 1 files changed, 28 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/sidlib.c	Sun Jan 05 23:51:04 2020 +0200
+++ b/sidlib.c	Mon Jan 06 00:05:16 2020 +0200
@@ -114,8 +114,7 @@
         !thfread_be32(ctx, &psid->speed))
     {
         ret = th_io_error(ctx, ctx->status,
-            "Could not read PSID/RSID header from '%s': %s.",
-            ctx->filename, th_error_str(ctx->status));
+            "Could not read PSID/RSID header.");
         goto exit;
     }
 
@@ -126,8 +125,7 @@
         psid->version < 1 || psid->version > 4)
     {
         ret = th_io_error(ctx, THERR_NOT_SUPPORTED,
-            "Not a supported PSID or RSID file: '%s'",
-            ctx->filename);
+            "Not a supported PSID or RSID file.");
         goto exit;
     }
 
@@ -138,8 +136,7 @@
         !sidlib_fread_str(ctx, &psid->sidCopyright, SIDLIB_PSID_STR_LEN))
     {
         ret = th_io_error(ctx, ctx->status,
-            "Error reading SID file header from '%s': %s.",
-            ctx->filename, th_error_str(ctx->status));
+            "Error reading SID file header data.");
         goto exit;
     }
 
@@ -154,8 +151,7 @@
             !thfread_u8(ctx, &psid->sid3Addr))
         {
             ret = th_io_error(ctx, ctx->status,
-                "Error reading PSID/RSID v2+ extra header data from '%s': %s.",
-                ctx->filename, th_error_str(ctx->status));
+                "Error reading PSID/RSID v2+ extra header data.");
             goto exit;
         }
     }
@@ -343,8 +339,7 @@
     if ((*pnode = node = (SIDLibSLDBNode *) th_malloc0(sizeof(SIDLibSLDBNode))) == NULL)
     {
         ret = th_io_error(ctx, THERR_MALLOC,
-            "Error allocating new SLDB node for SongLengthDB file '%s' line #%d:\n%s",
-            ctx->filename, ctx->line, line);
+            "Error allocating new SLDB node.");
         goto exit;
     }
 
@@ -361,8 +356,8 @@
     if (line[pos] != '=')
     {
         ret = th_io_error(ctx, THERR_INVALID_DATA,
-            "'=' expected on column %d of SongLengthDB file '%s' line #%d:\n%s",
-            pos, ctx->filename, ctx->line, line);
+            "'=' expected on column %d.",
+            pos);
         goto exit;
     }
 
@@ -392,8 +387,7 @@
     if ((node->lengths = (int *) th_calloc(node->nlengths, sizeof(int))) == NULL)
     {
         ret = th_io_error(ctx, THERR_MALLOC,
-            "Error allocating SLDB length data for SongLengthDB file '%s' line #%d:\n%s",
-            ctx->filename, ctx->line, line);
+            "Error allocating SLDB entry length data.");
         goto exit;
     }
 
@@ -463,8 +457,7 @@
             if (hashLen != TH_MD5HASH_LENGTH_CH)
             {
                 ret = th_io_error(ctx, THERR_INVALID_DATA,
-                    "Invalid MD5-hash in SongLengthDB file '%s' line #%d:\n%s",
-                    ctx->filename, ctx->line, line);
+                    "Invalid MD5-hash.");
                 goto exit;
             }
             else
@@ -480,8 +473,8 @@
         if (line[pos] != ';' && line[pos] != '[' && line[pos] != 0)
         {
             ret = th_io_error(ctx, THERR_INVALID_DATA,
-                "Invalid line in SongLengthDB file '%s' line #%d:\n%s",
-                ctx->filename, ctx->line, line);
+                "Invalid line / unexpected data at column #%d.",
+                pos);
             goto exit;
         }
     }
@@ -894,8 +887,8 @@
                 {
                     // Error! Invalid character found
                     ret = th_io_error(fh, THERR_INVALID_DATA,
-                        "Unexpected character '%c' on line #%d.",
-                         ctx.ch, fh->line);
+                        "Unexpected character '%c'.",
+                         ctx.ch);
                     goto out;
                 }
             }
@@ -928,8 +921,7 @@
                 else
                 {
                     ret = th_io_error(fh, THERR_INVALID_DATA,
-                        "Entry filename too long on line #%d.",
-                        fh->line);
+                        "STIL entry filename too long.");
                     goto out;
                 }
                 ctx.ch = -1;
@@ -947,16 +939,16 @@
                 if (!th_get_int(tmpStr, (unsigned int *) &subtune, &neg) || neg)
                 {
                     ret = th_io_error(fh, THERR_INVALID_DATA,
-                        "Entry '%s' subtune indicator not a valid integer on line #%d: '%s'",
-                        entry->filename, fh->line, tmpStr);
+                        "Entry '%s' subtune indicator '%s' is not a valid integer.",
+                        entry->filename, tmpStr);
                     goto out;
                 }
 
                 if (subtune <= 0 || subtune > 128)
                 {
                     th_io_error(fh, THERR_INVALID_DATA,
-                        "Entry '%s' subtune number %d is invalid on line #%d.",
-                        entry->filename, subtune, fh->line);
+                        "Entry '%s' subtune number #%d is out of range/invalid.",
+                        entry->filename, subtune);
 
                     subtune = -1;
                 }
@@ -973,8 +965,7 @@
                 else
                 {
                     ret = th_io_error(fh, THERR_INVALID_DATA,
-                        "Subtune indicator too long on line #%d.",
-                        fh->line);
+                        "Subtune indicator too long.");
                     goto out;
                 }
             }
@@ -983,8 +974,8 @@
             {
 sub_unexpected:
                 ret = th_io_error(fh, THERR_INVALID_DATA,
-                    "Unexpected character '%c' in subtune indicator on line #%d.",
-                    ctx.ch, fh->line);
+                    "Unexpected character '%c' in subtune indicator.",
+                    ctx.ch);
                 goto out;
             }
 
@@ -1003,8 +994,8 @@
                 if (entry == NULL)
                 {
                     ret = th_io_error(fh, THERR_INVALID_DATA,
-                        "No STIL entry allocated, but field '%s' found on line #%d.",
-                        fieldName, fh->line);
+                        "No STIL entry allocated, but field '%s' found.",
+                        fieldName);
                     goto out;
                 }
 
@@ -1018,8 +1009,7 @@
                 else
                 {
                     ret = th_io_error(fh, THERR_INVALID_DATA,
-                        "Field name too long on line #%d.",
-                        fieldName, fh->line);
+                        "Field name too long.");
                     goto out;
                 }
             }
@@ -1051,8 +1041,8 @@
                         entry, subtune, TRUE, field, tmpStr)) != THERR_OK)
                     {
                         ret = th_io_error(fh, THERR_MALLOC,
-                            "Could not allocate memory for field '%s' on line #%d.",
-                            fieldName, fh->line);
+                            "Could not allocate memory for field '%s'.",
+                            fieldName);
                         goto out;
                     }
                 }
@@ -1066,8 +1056,8 @@
                 else
                 {
                     ret = th_io_error(fh, THERR_INVALID_DATA,
-                        "Field '%s' data too long on line #%d.",
-                        fieldName, fh->line);
+                        "Field '%s' data too long.",
+                        fieldName);
                     goto out;
                 }
                 ctx.ch = - 1;