cancel
Showing results for 
Search instead for 
Did you mean: 

throw exception in graphical mapping or in using UDF ?

former_member229036
Participant
0 Kudos

Hi all;

i did search the issue through all article , but i did not get  an answer on SDN.

is there easy way to throw exception in graphical mapping or in using UDF ?

it will check if a value is empty, and then throw exception as mapping error  in sync interface.

Thank You

David.

Accepted Solutions (1)

Accepted Solutions (1)

markangelo_dihiansan
Active Contributor
0 Kudos

Hi David,

The best way to do this is to code the mapping logic in the response message root node. Just output result.addSuppress() in your UDF if the condition is not met and it will fail because the root node is mandatory. You can even use ifWithoutElse in the rootnode.

Regards,

Mark

former_member229036
Participant
0 Kudos

execution type is single value.  the follow is correct ?  it did not work

public String nullcheckthrow(String var1, Container container) throws StreamTransformationException{

if (!var1.equals("")) {

   return var1;

}else {

       // want to throw exception as mapping error

       return.addSuppress();

  

}

Harish
Active Contributor
0 Kudos

Hi David,

I think you need Context UDF to add the suppress. Please check the below blog which gave similar UDF to throw exception

RaghuVamseedhar
Active Contributor
0 Kudos

David,

Use this code

if (!var1.equals("")) {

    return var1;

} else {

    throw new StreamTransformationException("Here is error message");

}


    public String calculate1(String var1, Container container) throws StreamTransformationException {

        if (!var1.equals("")) {

            return var1;

        } else {

            throw new StreamTransformationException("Here is error message");

        }

    }

Ryan-Crosby
Active Contributor
0 Kudos

Hi David,

I would use Raghu's suggestion above as it is guaranteed to throw an exception and you can control what information will be shown as part of the message as well as make it conditional.

Regards,

Ryan Crosby

Answers (1)

Answers (1)

iaki_vila
Active Contributor
0 Kudos