Sun Aug 25, 2019 5:39 am
Login Register Lost Password? Contact Us


Getting all messages from a WU,

Share ideas, code, best practices and techniques with other community members

Wed May 22, 2019 10:48 am Change Time Zone

Hi,
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: 375
Joined: Sat Oct 01, 2011 7:26 pm

Wed May 22, 2019 3:12 pm Change Time Zone

Thanks for the contribution, Allan!!
rtaylor
Community Advisory Board Member
Community Advisory Board Member
 
Posts: 1472
Joined: Wed Oct 26, 2011 7:40 pm

Thu May 23, 2019 8:02 am Change Time Zone

Raised ticket:
https://track.hpccsystems.com/browse/HPCC-22196
to get functionality incorporated into HPCC/ECL
Allan
 
Posts: 375
Joined: Sat Oct 01, 2011 7:26 pm


Return to Tips & Tricks

Who is online

Users browsing this forum: No registered users and 1 guest

cron