Skip to content

Commit

Permalink
HPCC-30577 Improve error reporting on problem in IFBLOCK() condition
Browse files Browse the repository at this point in the history
Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
  • Loading branch information
ghalliday committed Oct 25, 2023
1 parent dee5965 commit cf81d63
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 7 deletions.
37 changes: 31 additions & 6 deletions ecl/hqlcpp/hqlhtcpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4456,9 +4456,17 @@ class MetaMemberCallback
break;
case no_ifblock:
{
OwnedHqlExpr cond = replaceSelector(cur->queryChild(0), querySelfReference(), selector);
BuildCtx condctx(ctx);
translator.buildFilter(condctx, cond);
try
{
OwnedHqlExpr cond = replaceSelector(cur->queryChild(0), querySelfReference(), selector);
translator.buildFilter(condctx, cond);
}
catch(IException * _e)
{
Owned<IException> e(_e);
throw makePrefixedException("Error processing IFBLOCK() condition: ", e);
}
walkRecord(condctx, selector, cur->queryChild(1));
break;
}
Expand Down Expand Up @@ -10158,9 +10166,17 @@ void HqlCppTranslator::buildCsvWriteTransform(BuildCtx & subctx, IHqlExpression
}
case no_ifblock:
{
OwnedHqlExpr cond = replaceSelector(expr->queryChild(0), querySelfReference(), selector);
BuildCtx condctx(subctx);
buildFilter(condctx, cond);
try
{
OwnedHqlExpr cond = replaceSelector(expr->queryChild(0), querySelfReference(), selector);
buildFilter(condctx, cond);
}
catch(IException * _e)
{
Owned<IException> e(_e);
throw makePrefixedException("Error processing IFBLOCK() condition: ", e);
}
buildCsvWriteTransform(condctx, expr->queryChild(1), selector, encoding);
break;
}
Expand Down Expand Up @@ -11617,9 +11633,18 @@ void HqlCppTranslator::buildXmlSerialize(BuildCtx & subctx, IHqlExpression * exp
break;
case no_ifblock:
{
OwnedHqlExpr cond = replaceSelector(expr->queryChild(0), querySelfReference(), selector);
BuildCtx condctx(subctx);
buildFilter(condctx, cond);
try
{
OwnedHqlExpr cond = replaceSelector(expr->queryChild(0), querySelfReference(), selector);
buildFilter(condctx, cond);
}
catch(IException * _e)
{
Owned<IException> e(_e);
throw makePrefixedException("Error processing IFBLOCK() condition: ", e);
}

buildXmlSerialize(condctx, expr->queryChild(1), selector, assigns, pass, expectedIndex);
}
break;
Expand Down
10 changes: 9 additions & 1 deletion system/jlib/jexcept.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,19 @@ IException *makeStringExceptionV(MessageAudience aud, int code, const char *form
return ret;
}

IException jlib_decl *makeStringException(MessageAudience aud,int code,const char *why)
IException *makeStringException(MessageAudience aud,int code,const char *why)
{
return new StringException(code,why,aud);
}

IException *makePrefixedException(const char * prefix, const IException * e)
{
StringBuffer msg;
e->errorMessage(msg.append(prefix));
return makeStringException(e->errorAudience(), e->errorCode(), msg);
}


class jlib_thrown_decl WrappedException: public StringException
{
typedef StringException PARENT;
Expand Down
1 change: 1 addition & 0 deletions system/jlib/jexcept.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ IException jlib_decl *makeStringException(int code, const char *why);
IException jlib_decl *makeStringExceptionV(MessageAudience aud, int code, const char *why, ...) __attribute__((format(printf, 3, 4)));
IException jlib_decl *makeStringExceptionVA(MessageAudience aud, int code, const char *why, va_list args) __attribute__((format(printf, 3, 0)));
IException jlib_decl *makeStringException(MessageAudience aud, int code, const char *why);
IException jlib_decl *makePrefixedException(const char * prefix, const IException * e);
__declspec(noreturn) void jlib_decl throwStringExceptionV(int code, const char *format, ...) __attribute__((format(printf, 2, 3), noreturn));
IException jlib_decl *makeWrappedExceptionVA(IException *e, int code, const char *why, va_list args) __attribute__((format(printf, 3, 0)));
IException jlib_decl *makeWrappedExceptionV(IException *e, int code, const char *why, ...) __attribute__((format(printf, 3, 4)));
Expand Down

0 comments on commit cf81d63

Please sign in to comment.