Browse Source

HPCC-13096 Improve error message accessing invalid graph result

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday 10 năm trước cách đây
mục cha
commit
d211634094
2 tập tin đã thay đổi với 8 bổ sung1 xóa
  1. 2 0
      ecl/hqlcpp/hqlcerrors.hpp
  2. 6 1
      ecl/hqlcpp/hqlcppds.cpp

+ 2 - 0
ecl/hqlcpp/hqlcerrors.hpp

@@ -313,6 +313,7 @@
 #define HQLERR_DependencyWithinGraph            4836
 #define HQLERR_UnknownCompoundAssign            4837
 #define HQLERR_ReadSpillBeforeWriteFix          4838
+#define HQLERR_AccessUnavailableGraph           4839
 //#define HQLERR_Max                            4999
 
 //---- Text for all errors (make it easy to internationalise) ---------------------------
@@ -593,6 +594,7 @@
 #define HQLERR_UnknownCompoundAssign_Text       "INTERNAL: Unrecognised compound assign %s"
 #define HQLERR_ReadSpillBeforeWriteFix_Text     "INTERNAL: Attempt to read spill file %s before it is written.  Try adding #option ('allowThroughSpill', false); to the query."
 #define HQLERR_CouldNotGenerateDefault_Text     "INTERNAL: Could not generate default value for field %s"
+#define HQLERR_AccessUnavailableGraph_Text      "INTERNAL: Attempt to access result from unavailable graph (%s)"
 
 #define WARNINGAT(cat, e, x)                 reportWarning(cat, SeverityUnknown, e, x, x##_Text)
 #define WARNINGAT1(cat, e, x, a)             reportWarning(cat, SeverityUnknown, e, x, x##_Text, a)

+ 6 - 1
ecl/hqlcpp/hqlcppds.cpp

@@ -56,7 +56,12 @@
 void addGraphIdAttribute(ActivityInstance * instance, BuildCtx & ctx, IHqlExpression * graphId)
 {
     SubGraphInfo * match = matchActiveGraph(ctx, graphId);
-    assertex(match);
+    if (!match)
+    {
+        StringBuffer graphname;
+        graphname.append(graphId->queryChild(0)->querySequenceExtra());
+        throwError1(HQLERR_AccessUnavailableGraph, graphname.str());
+    }
     instance->addAttributeInt("_graphId", match->graphId);
 }