Skip to main content
Tweeted twitter.com/StackSalesforce/status/1020656308205367296
added 1 character in body
Source Link
sfdcfox
  • 501.9k
  • 21
  • 473
  • 828

I have made a test LightingLightning app to figure out why error catching isn't working as I expected.

Component: aura:component

<aura:handler name="init" value="{!this}" action="{!c.doInit}" />

</aura:component>

Controller:

({
    // Handle component initialization
    doInit : function(component, event, helper) {
        $A.logger.subscribe("INFO", logCustom);
        $A.log('initialized logger');

        function logCustom(level, message, error) {
            console.log(getTimestamp());
            console.log(error);
            console.log(error.stack)
        }

        function getTimestamp() {
            return new Date().toJSON();
        }

    }

})

Error:

"Something has gone wrong. Error during init [Action failed: c$JQTest$controller$doInit [TypeError: Cannot read property 'subscribe' of undefined]]"

heroku lightning:lint

  error       aura-api     Invalid Aura API                    
  Line:4:9
          $A.logger.subscribe("INFO", logCustom);
           ^

Perhaps I'm super confused... is $A.logger no longer supported? If not what is the new preferred way to catch errors? Thanks!

I have made a test Lighting app to figure out why error catching isn't working as I expected.

Component: aura:component

<aura:handler name="init" value="{!this}" action="{!c.doInit}" />

</aura:component>

Controller:

({
    // Handle component initialization
    doInit : function(component, event, helper) {
        $A.logger.subscribe("INFO", logCustom);
        $A.log('initialized logger');

        function logCustom(level, message, error) {
            console.log(getTimestamp());
            console.log(error);
            console.log(error.stack)
        }

        function getTimestamp() {
            return new Date().toJSON();
        }

    }

})

Error:

"Something has gone wrong. Error during init [Action failed: c$JQTest$controller$doInit [TypeError: Cannot read property 'subscribe' of undefined]]"

heroku lightning:lint

  error       aura-api     Invalid Aura API                    
  Line:4:9
          $A.logger.subscribe("INFO", logCustom);
           ^

Perhaps I'm super confused... is $A.logger no longer supported? If not what is the new preferred way to catch errors? Thanks!

I have made a test Lightning app to figure out why error catching isn't working as I expected.

Component: aura:component

<aura:handler name="init" value="{!this}" action="{!c.doInit}" />

</aura:component>

Controller:

({
    // Handle component initialization
    doInit : function(component, event, helper) {
        $A.logger.subscribe("INFO", logCustom);
        $A.log('initialized logger');

        function logCustom(level, message, error) {
            console.log(getTimestamp());
            console.log(error);
            console.log(error.stack)
        }

        function getTimestamp() {
            return new Date().toJSON();
        }

    }

})

Error:

"Something has gone wrong. Error during init [Action failed: c$JQTest$controller$doInit [TypeError: Cannot read property 'subscribe' of undefined]]"

heroku lightning:lint

  error       aura-api     Invalid Aura API                    
  Line:4:9
          $A.logger.subscribe("INFO", logCustom);
           ^

Perhaps I'm super confused... is $A.logger no longer supported? If not what is the new preferred way to catch errors? Thanks!

Source Link

LockerService not allowing subscribing to $A.logger

I have made a test Lighting app to figure out why error catching isn't working as I expected.

Component: aura:component

<aura:handler name="init" value="{!this}" action="{!c.doInit}" />

</aura:component>

Controller:

({
    // Handle component initialization
    doInit : function(component, event, helper) {
        $A.logger.subscribe("INFO", logCustom);
        $A.log('initialized logger');

        function logCustom(level, message, error) {
            console.log(getTimestamp());
            console.log(error);
            console.log(error.stack)
        }

        function getTimestamp() {
            return new Date().toJSON();
        }

    }

})

Error:

"Something has gone wrong. Error during init [Action failed: c$JQTest$controller$doInit [TypeError: Cannot read property 'subscribe' of undefined]]"

heroku lightning:lint

  error       aura-api     Invalid Aura API                    
  Line:4:9
          $A.logger.subscribe("INFO", logCustom);
           ^

Perhaps I'm super confused... is $A.logger no longer supported? If not what is the new preferred way to catch errors? Thanks!