[esnacc-dev] [PATCH] Improved error reporting for SEQUENCE tags - added fieldName that caused the error

Charles Wright charles_wright at azimuthsystems.com
Fri Jul 22 12:32:57 UTC 2016


Looks good!  I may try to find other places where a fieldname can be added to an error message - seems like an easy enhancement.

Charles

-----Original Message-----
From: Aaron Conole [mailto:aconole at bytheb.org] 
Sent: Thursday, July 21, 2016 11:42 PM
To: Charles Wright
Cc: dev at lists.esnacc.org
Subject: Re: [esnacc-dev] [PATCH] Improved error reporting for SEQUENCE tags - added fieldName that caused the error

Charles Wright <charles_wright at azimuthsystems.com> writes:

> ---
>  compiler/back-ends/c++-gen/gen-code.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/compiler/back-ends/c++-gen/gen-code.c b/compiler/back-ends/c++-gen/gen-code.c
> index 444bc8d..f8a091c 100644
> --- a/compiler/back-ends/c++-gen/gen-code.c
> +++ b/compiler/back-ends/c++-gen/gen-code.c
> @@ -2742,7 +2742,7 @@ PrintCxxSeqDefCode (FILE *src, FILE *hdr, ModuleList *mods, Module *m,
>                      }
>                      else
>                      {
> -                        fprintf (src, "      throw EXCEPT(\"SEQUENCE is missing non-optional root elmt\", DECODE_ERROR);\n");
> +                        fprintf (src, "      throw EXCEPT(\"SEQUENCE is missing non-optional root elmt (%s)\", DECODE_ERROR);\n", e->fieldName);
>                      }
>                      fprintf (src, "  }\n\n");
>                  }

Thanks for your contribution.  I rewrote your commit message as follows:

    compiler/c++-gen: Improved error reporting for SEQUENCE tags

    This commit adds an additional output which includes the fieldName
    that caused the error.

    Signed-off-by: Charles Wright <charles_wright at azimuthsystems.com>


And I reformatted your code as follows, and applied to master.

-Aaron

---
diff --git a/compiler/back-ends/c++-gen/gen-code.c b/compiler/back-ends/c++-gen/gen-code.c
index 444bc8d..6809858 100644
--- a/compiler/back-ends/c++-gen/gen-code.c
+++ b/compiler/back-ends/c++-gen/gen-code.c
@@ -2742,7 +2742,9 @@ PrintCxxSeqDefCode (FILE *src, FILE *hdr, ModuleList *mods, Module *m,
                     }
                     else
                     {
-                        fprintf (src, "      throw EXCEPT(\"SEQUENCE is missing non-optional root elmt\", DECODE_ERROR);\n");
+                        fprintf (src,
+                                 "      throw EXCEPT(\"SEQUENCE is missing non-optional root elmt (%s)\", DECODE_ERROR);\n",
+                                 e->fieldName);
                     }
                     fprintf (src, "  }\n\n");
                 }



More information about the dev mailing list