Expected type Exception; found [System.AuraHandledException, AuraHandledException]

Issue #1425 resolved
Oleh Berehovskyi created an issue

Using AuraHandledException or System.AuraHandledException causes false-positive error highlighting of the code:

Expected type Exception; found [System.AurahandledException, AurahandledException]

For instance, throwing new DmlException() from catch (Exception exc) block doesn’t cause this bug, although both AuraHandledException and DmlException extend Exception class. This false-positive illegal assignment error occurs only in Intellij Idea 2019.2.3. WebStorm 2019.2.' behaves properly. I tried to reinstall IDEA but it didn’t help. Both Idea and WebStorm have 11.0.4 runtime version and the same inspection profile settings. I'm not sure if this issue is only related to Intellij Idea or Illuminated Cloud 2.

Comments (12)

  1. Scott Wells repo owner

    Do you happen to have a .sfdx/tools/sobjects folder in this project? If so, IC should have provided a toaster notification saying that you should exclude it. Please do so, whether by allowing IC to do it for you or by using Right-Click>Mark Directory as>Excluded against that folder.

    If you don't have such a folder, I'll need to investigate further, but let's start with what may be the simplest cause/solution.

  2. Oleh Berehovskyi reporter

    Unfortunately, I don’t have .sfdx/tools/sobjects folder in my project. The strange thing is that when I open the same project in WebStorm, this bug does not exist, but in IntelliJ Idea it does.

  3. Scott Wells repo owner

    Okay. If you open the AuraHandledException class, what does it look like? For me it looks like:

    // Generated by Illuminated Cloud on Mon Sep 23 13:09:49 CDT 2019. Do not edit.
    
    global class /*System.*/AuraHandledException extends Exception 
    {
    
    }
    
  4. Scott Wells repo owner

    Thanks for confirming. In IntelliJ IDEA, do you mind using Rebuild Caches and Indices in Illuminated Cloud>Configure Project, then allow the project to close and reopen and see if that resolves the issue or not? I'm wondering if the index for inheritance relationships has gotten into a bad state or something. If that doesn't resolve it I'll dig in more on my side and see if I can reproduce it.

  5. Oleh Berehovskyi reporter

    Yes, using Rebuild Caches and Indices in Illuminated Cloud>Configure Project resolved this issue. But why regenerating the offline symbol table multiple times with reloading the IDEA didn’t help then? Anyway, thank you, Scott. Your tip completely resolved my issue.

  6. Scott Wells repo owner

    Okay, that's good to hear. I can't explain why OST regeneration followed by project reload wouldn't do the same thing as the last step of that is to rebuild caches and indices. I'll take a look and see if I can figure out any difference in behavior between the two.

  7. Justin Julicher

    Hi Scott

    Got an issue that is very similar to this one - not sure if it’s the same.

    You should be able to reproduce it with this scratch or file:

    public class Filters {
        public interface Filter {
            Boolean apply(Object toFilter);
        }
    
        public interface Function {
            Object call(Object functionObject);
        }
    
        public abstract class ObjectFilter implements Function, Filter {
            public Object call(Object functionObject) {
                return apply(functionObject) ? functionObject : null;
            }
    
            public abstract Boolean apply(Object toFilter);
        }
    
        public abstract class SObjectFilter extends ObjectFilter {
    
            public override Boolean apply(Object toFilter) {
                return apply((SObject) toFilter);
            }
    
            public abstract Boolean apply(SObject toFilter);
        }
    
        private class FilterException extends Exception {
        }
    
        public abstract class StandardFilter extends SObjectFilter {
            protected final SObjectField field;
            protected final Object value;
    
            public StandardFilter(SObjectField field, Object value) {
                this.field = field;
                this.value = value;
            }
    
            public abstract override Boolean apply(SObject obj);
        }
    
        public virtual class EqualsFilter extends StandardFilter {
            public EqualsFilter(SObjectField field, Object value) {
                super(field, value);
            }
    
            public virtual override Boolean apply(SObject record) {
                Object leftValue = ((SObject) record).get(this.field);
                return leftValue == this.value;
            }
        }
    
        public class isNull extends EqualsFilter {
            public isNull(SObjectField field) {
                super(field, null);
            }
        }
    
        public class NotNull extends NotEqual {
            public NotNull(SObjectField field) {
                super(field, null);
            }
        }
    }
    

    thanks

  8. Log in to comment