Getting all messages from a WU,
Hi,
ECL built-in FAILMESSAGE just returns the LAST error message form a Workunit.
99% of the time this is just:
The actual error is an earlier message. This is especially annoying when you crash out with an ASSERT...,FAIL. The ASSERTion message is NOT the last message.
The function below returns all messages from a Workunit. You can also filter by the severity of the message, one of 'info', warning' or 'error'. (Note a message type of a particular severity, also returns all messages of a higher severity)
To use:
Might save 10 seconds of peoples lives.
Yours
Allan
ECL built-in FAILMESSAGE just returns the LAST error message form a Workunit.
99% of the time this is just:
- Code: Select all
4294967295, eclagent, System error: -1: Abort execution
The actual error is an earlier message. This is especially annoying when you crash out with an ASSERT...,FAIL. The ASSERTion message is NOT the last message.
The function below returns all messages from a Workunit. You can also filter by the severity of the message, one of 'info', warning' or 'error'. (Note a message type of a particular severity, also returns all messages of a higher severity)
- Code: Select all
GetWUMessages(STRING Wuid,STRING MessageType = 'error') := FUNCTION
/*
Note a message type of a particular severity, also returns all messages of a higher severity.
*/
Chk := ASSERT(MessageType IN ['info','warning','error'],'MessageType must be one of \'info\', \'warning\' or \'error\'.',FAIL);
rWURequest :=
record
string Wuid{XPATH('Wuid')} := Wuid;
STRING ExceptionSeverity{XPATH('ExceptionSeverity')} := MessageType;
end;
rWUResponse :=
record
string Wuid{XPATH('Wuid'),maxlength(20)};
string Results{XPATH('Results')};
end;
dWUResult := soapcall( 'http://<Ip:port e.g. 1.2.3.4:8010>/WsWorkunits',
'WUFullResult',
rWURequest,
rWUResponse,
XPATH('WUFullResultResponse')
);
// Convert XML reponse into something readable.
RLine := RECORD
STRING Code{xpath('Code')};
STRING Filename{xpath('Filename')};
STRING Line{xpath('Line')};
STRING Source{xpath('Source')};
STRING Message{xpath('Message')};
END;
ROut := RECORD
DATASET(RLine) Results{XPATH('*')};
END;
Out := DATASET(FROMXML(ROut,dWUResult.Results));
T(STRING s) := IF(s = '','',', '+s);
RETURN MODULE
EXPORT AsXML := WHEN(dWUResult.Results,chk);
EXPORT AsDATASET := WHEN(NORMALIZE(Out,LEFT.Results,TRANSFORM(RIGHT)),chk);
EXPORT AsString := WHEN(NORMALIZE(Out,LEFT.Results,TRANSFORM({STRING Message}
;SELF.Message := RIGHT.Code
+ T(RIGHT.Filename)
+ T(RIGHT.Line)
+ T(RIGHT.Source)
+ T(RIGHT.Message))),chk);
END;
END;
To use:
- Code: Select all
f := GetWUMessages('W20190522-100123','error');
f.AsXML;
f.AsDATASET;
f.AsString;
Might save 10 seconds of peoples lives.
Yours
Allan
- Allan
- Posts: 444
- Joined: Sat Oct 01, 2011 7:26 pm
Thanks for the contribution, Allan!!
- rtaylor
- Community Advisory Board Member
- Posts: 1619
- Joined: Wed Oct 26, 2011 7:40 pm
Raised ticket:
https://track.hpccsystems.com/browse/HPCC-22196
to get functionality incorporated into HPCC/ECL
https://track.hpccsystems.com/browse/HPCC-22196
to get functionality incorporated into HPCC/ECL
- Allan
- Posts: 444
- Joined: Sat Oct 01, 2011 7:26 pm
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest