3

Why am I getting the error:

Class.zced.RPGFlowBackendController.createBlankPhrase: line 368, column 1 09:12:54.0 (3312262)|FATAL_ERROR|System.UnexpectedException: Illegal arguments

Class.zced.RPGFlowBackendController.createBlankPhrase: line 368, column 1 09:12:54.0 (3336027)|CODE_UNIT_FINISHED|RPGFlowBackendController.createBlankPhrase(String, Integer) 09:12:54.0 (8586550)|CODE_UNIT_FINISHED|Aura 09:12:54.0 (9669770)|EXECUTION_FINISHED

@AuraEnabled
    public static void createBlankPhrase(String interactionId, Integer firstSequence) {
        List<zced__Dialogue_Item__c> res = new List<zced__Dialogue_Item__c>();
        res.add(new zced__Dialogue_Item__c(
                zced__Character_Position__c = 'Left',
                zced__Sequence__c = firstSequence,
                zced__Interaction__c = interactionId
        ));
        res.add(new zced__Dialogue_Item__c(
                zced__Character_Position__c = 'Right',
                zced__Sequence__c = firstSequence + 1,
                zced__Interaction__c = interactionId
        ));
        INSERT res;
    }

enter image description here

I checked that the interactionId is correct and firstSequence is correct as well. I see no reasons for an error to be thrown here.

I am not sure whether or not it is necessary, but here is the whole log of the method call:

43.0 APEX_CODE,FINEST;APEX_PROFILING,ERROR;CALLOUT,ERROR;DB,DEBUG;NBA,INFO;SYSTEM,FINEST;VALIDATION,ERROR;VISUALFORCE,ERROR;WAVE,INFO;WORKFLOW,ERROR 09:12:54.0 (93686)|UNKNOWN|[EXTERNAL]|0051r000007genI|[email protected]|Greenwich Mean Time|GMT+01:00 09:12:54.0 (130561)|EXECUTION_STARTED 09:12:54.0 (134596)|CODE_UNIT_STARTED|[EXTERNAL]|Aura 09:12:54.0 (687052)|HEAP_ALLOCATE|[72]|Bytes:3 09:12:54.0 (747183)|HEAP_ALLOCATE|[77]|Bytes:152 09:12:54.0 (766706)|HEAP_ALLOCATE|[342]|Bytes:408 09:12:54.0 (787010)|HEAP_ALLOCATE|[355]|Bytes:408 09:12:54.0 (806043)|HEAP_ALLOCATE|[467]|Bytes:48 09:12:54.0 (840047)|HEAP_ALLOCATE|[139]|Bytes:6 09:12:54.0 (869996)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:18 09:12:54.0 (878842)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:18 09:12:54.0 (1819221)|CODE_UNIT_STARTED|[EXTERNAL]|01p1r00000EwmQM|RPGFlowBackendController.createBlankPhrase(String, Integer) 09:12:54.0 (1938310)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:53 09:12:54.0 (1987501)|METHOD_ENTRY|1|01p1r00000EwmQM|RPGFlowBackendController.RPGFlowBackendController() 09:12:54.0 (1998322)|STATEMENT_EXECUTE|1 09:12:54.0 (2005729)|STATEMENT_EXECUTE|1 09:12:54.0 (2047442)|HEAP_ALLOCATE|[50]|Bytes:5 09:12:54.0 (2076935)|HEAP_ALLOCATE|[56]|Bytes:5 09:12:54.0 (2088848)|HEAP_ALLOCATE|[64]|Bytes:7 09:12:54.0 (2110792)|SYSTEM_MODE_ENTER|false 09:12:54.0 (2128022)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:5 09:12:54.0 (2138777)|SYSTEM_MODE_EXIT|false 09:12:54.0 (2150181)|METHOD_EXIT|1|RPGFlowBackendController 09:12:54.0 (2162802)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:18 09:12:54.0 (2180947)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:28 09:12:54.0 (2190685)|SYSTEM_MODE_ENTER|false 09:12:54.0 (2303063)|VARIABLE_SCOPE_BEGIN|[366]|interactionId|String|false|false 09:12:54.0 (2339022)|VARIABLE_ASSIGNMENT|[366]|interactionId|"a0A1r00002sKpsBEAS" 09:12:54.0 (2349728)|VARIABLE_SCOPE_BEGIN|[366]|firstSequence|Integer|false|false 09:12:54.0 (2366585)|VARIABLE_ASSIGNMENT|[366]|firstSequence|2 09:12:54.0 (2384581)|HEAP_ALLOCATE|[367]|Bytes:5 09:12:54.0 (2392981)|STATEMENT_EXECUTE|[366] 09:12:54.0 (2395785)|STATEMENT_EXECUTE|[367] 09:12:54.0 (2415810)|HEAP_ALLOCATE|[367]|Bytes:4 09:12:54.0 (2467906)|SYSTEM_CONSTRUCTOR_ENTRY|[367]|() 09:12:54.0 (2507531)|SYSTEM_CONSTRUCTOR_EXIT|[367]|() 09:12:54.0 (2516882)|VARIABLE_SCOPE_BEGIN|[367]|res|List|true|false 09:12:54.0 (2534427)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:4 09:12:54.0 (2550607)|VARIABLE_ASSIGNMENT|[367]|res|[]|0x4e7822de 09:12:54.0 (2559706)|STATEMENT_EXECUTE|[368] 09:12:54.0 (2616580)|HEAP_ALLOCATE|[368]|Bytes:4 09:12:54.0 (2728540)|HEAP_ALLOCATE|[369]|Bytes:4 09:12:54.0 (2789080)|VARIABLE_ASSIGNMENT|[368]|this.zced__Character_Position__c|"Left"|0x7d37e303 09:12:54.0 (3164854)|HEAP_ALLOCATE|[368]|Bytes:21 09:12:54.0 (3292538)|FATAL_ERROR|System.UnexpectedException: Illegal arguments

Class.zced.RPGFlowBackendController.createBlankPhrase: line 368, column 1 09:12:54.0 (3312262)|FATAL_ERROR|System.UnexpectedException: Illegal arguments

Class.zced.RPGFlowBackendController.createBlankPhrase: line 368, column 1 09:12:54.0 (3336027)|CODE_UNIT_FINISHED|RPGFlowBackendController.createBlankPhrase(String, Integer) 09:12:54.0 (8586550)|CODE_UNIT_FINISHED|Aura 09:12:54.0 (9669770)|EXECUTION_FINISHED

Here is the client side controller code which calls the apex:

helper.executeBackendRequest({
                component: component,
                apexMethodName: "c.createBlankPhrase",
                params: {
                    interactionId: arg.auraAttributesData.interactionId,
                    firstSequence: 2
                },
                requestCallback: function(){}
            });

executeBackendRequest: function(info) {
        const action = info.component.get(info.apexMethodName);
        action.setParams(info.params);
        action.setCallback(info.component, info.requestCallback);
        $A.getCallback(function(){$A.enqueueAction(action);})();
    }
2
  • Can you paste the code your lightning js code from where you are passing these parameters. This issue may happen if you are passing string on the place of integer...firstSequence
    – Ayub
    Commented Jul 5, 2018 at 8:42
  • Integers don't work in Aura, use Double and Integer.valueOf(myDoubleTrouble)
    – dzh
    Commented Jul 5, 2018 at 8:54

2 Answers 2

3

There are a few blogs written about issues like this (here is a good example) where as @dzh correctly points out, integers cause issues.

Try recasting the variable before using it, so effectively add the line

firstSequence = Integer.valueOf(firstSequence);

at 367 and you should be good to go.

0

A bit late to the party, but I found another way of causing this to occur. If you have an interface with methods returning Decimal, but the implementations return Double, then instead of catching this at compile time, it can cause

System.UnexpectedException: Illegal arguments

at runtime.

Here's a simple test which exposes the problem:

@IsTest
static void testNumbers() {
    Numbers n = new NumbersImpl();
    Decimal d1 = n.getDecimal();
    Decimal d2 = n.getOtherDecimal();
    Boolean same = d1==d2; //exception occurs here
    System.assert(same);
}

private interface Numbers {
    Decimal getDecimal();
    Decimal getOtherDecimal();
}

private class NumbersImpl implements Numbers {
    private Double d1 = 3;
    private Double d2 = 3;
    public Double getDecimal() {
        return d1;
    }
    public Double getOtherDecimal() {
        return d2;
    }
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .