[SalesForce] Cannot Read Property ‘ErrorCode’ Of Undefined in Lightning Component on Community

I am building a lightning component that needs to allow a series of fields on Case to updated by a community user. This component loads up just fine in Lightning Experience, and even in the Community Builder preview. But when I login to the community as an actual user I see this error:
**

Cannot Read Property 'ErrorCode' Of Undefined

**
I realize this is likely a record permission or a field accessibility issue, but I have checked and the community profile has visibility and edit permissions to the field. As well as Read/Create/Update on the Case object. Interestingly however, if I load up the case detail standard page layout in community the field is editable. So this seems to be isolated to the lightning:recordEditForm component. Any ideas how to solve for this?

<aura:component implements="forceCommunity:availableForAllPageTypes,flexipage:availableForAllPageTypes,force:hasRecordId" >
<aura:attribute name="recordId" type="String"/>
<lightning:recordEditForm recordId="{!v.recordId}" objectApiName="Case" onerror="{!c.getError}" onload="{!c.onLoad}">
    <lightning:messages />
    <lightning:inputField fieldName="Description" />

    <lightning:button class="slds-m-top_small" variant="brand" type="submit" name="update" label="Update" />
</lightning:recordEditForm>

getError : function(component, event, helper){
        debugger;
        var errorObj = event.getParams();
        var errorString = JSON.stringify(errorObj);
        console.log("@@@@:   " + errorString);
    }

EDIT***
Some additional information, looks like ErrorCode is a paramater returned by the onerror event object. Strinigfy spits out the whole error:

{"message":"Cannot read property 'errorCode' of
undefined","detail":"","output":{},"error":{"type":"TRANSPORT_ERROR","details":{}}}

Best Answer

Trace where your errorCode is located. What the message really means is that the project you are working on cannot find any element, property, or object named errorCode.

This usually happens when you are having typographical errors on variable, method or object name which you are calling.

I will give you an example:

I have an aura attribute <aura:attribute name="errorCode" type="String"/> and I am assigning values to this attribute inside my controller by component.set('v.errorCodes', 'This is an Error'); Notice that the attribute name and the component.set assignment names are different. It will throw you an error

Cannot read property 'errorCodes' of undefined"

Its because you dont have any attribute named errorCodes in your component.

There is usually a trace code for this, have you tried tracing the source of the error by opening the Inspector in your browser?