mbeckerle commented on a change in pull request #525:
URL: https://github.com/apache/daffodil/pull/525#discussion_r610760668



##########
File path: daffodil-runtime2/src/main/resources/c/libruntime/errors.h
##########
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ERRORS_H
+#define ERRORS_H
+
+#include <stdio.h>    // for FILE, size_t
+#include <stdint.h>   // for int64_t
+
+// ErrorCode - types of errors which could occur
+
+enum ErrorCode
+{
+    ERR_CHOICE_KEY,
+    ERR_FILE_CLOSE,
+    ERR_FILE_FLUSH,
+    ERR_FILE_OPEN,
+    ERR_FIXED_VALUE,
+    ERR_INFOSET_READ,
+    ERR_INFOSET_WRITE,
+    ERR_PARSE_BOOL,
+    ERR_STACK_EMPTY,
+    ERR_STACK_OVERFLOW,
+    ERR_STACK_UNDERFLOW,
+    ERR_STREAM_EOF,
+    ERR_STREAM_ERROR,
+    ERR_STRTOBOOL,
+    ERR_STRTOD_ERRNO,
+    ERR_STRTOI_ERRNO,
+    ERR_STRTONUM_EMPTY,
+    ERR_STRTONUM_NOT,
+    ERR_STRTONUM_RANGE,
+    ERR_XML_DECL,
+    ERR_XML_ELEMENT,
+    ERR_XML_ERD,
+    ERR_XML_GONE,
+    ERR_XML_INPUT,
+    ERR_XML_LEFT,
+    ERR_XML_MISMATCH,
+    ERR_XML_WRITE
+};
+
+// Error - specific error occuring now
+
+typedef struct Error
+{
+    enum ErrorCode code;
+    union
+    {
+        const char *s;   // for %s
+        int64_t     d64; // for %d64
+    };
+} Error;
+
+// Diagnostics - array of validation errors
+
+typedef struct Diagnostics
+{
+    Error  array[100];

Review comment:
       This 100 needs to be a named constant, and adding diagnostics needs to 
check against it, which suggests there should be an addDiagnostic(...) 
abstraction to centralize the check, and when exceeded, this 100 can only 
result in a fatal/abort, which is ok, but centralizing that seems quite 
important. 

##########
File path: daffodil-runtime2/src/main/resources/c/libruntime/errors.h
##########
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ERRORS_H
+#define ERRORS_H
+
+#include <stdio.h>    // for FILE, size_t
+#include <stdint.h>   // for int64_t
+
+// ErrorCode - types of errors which could occur
+
+enum ErrorCode
+{
+    ERR_CHOICE_KEY,
+    ERR_FILE_CLOSE,
+    ERR_FILE_FLUSH,
+    ERR_FILE_OPEN,
+    ERR_FIXED_VALUE,
+    ERR_INFOSET_READ,
+    ERR_INFOSET_WRITE,
+    ERR_PARSE_BOOL,
+    ERR_STACK_EMPTY,
+    ERR_STACK_OVERFLOW,
+    ERR_STACK_UNDERFLOW,
+    ERR_STREAM_EOF,
+    ERR_STREAM_ERROR,
+    ERR_STRTOBOOL,
+    ERR_STRTOD_ERRNO,
+    ERR_STRTOI_ERRNO,
+    ERR_STRTONUM_EMPTY,
+    ERR_STRTONUM_NOT,
+    ERR_STRTONUM_RANGE,
+    ERR_XML_DECL,
+    ERR_XML_ELEMENT,
+    ERR_XML_ERD,
+    ERR_XML_GONE,
+    ERR_XML_INPUT,
+    ERR_XML_LEFT,
+    ERR_XML_MISMATCH,
+    ERR_XML_WRITE
+};
+
+// Error - specific error occuring now
+
+typedef struct Error
+{
+    enum ErrorCode code;
+    union
+    {
+        const char *s;   // for %s

Review comment:
       I expected to see an ERD or other context-containing object passed as 
well so that a diagnostic can talk about the context of the error.  I expect 
ERDs would eventually contain schema-component identifiers allowing 
file/line-no of the schema construct where the runtime-error is occurring to be 
part of the messaging. 
   
   You are allowing only 1 "argument" to the error, a string or int64. That's 
certainly ok for now. I was thinking you might need a way to pass the info item 
as another alternative. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to