Error and console logging is useful to help with troubleshooting your skill or to view shapes of PrecisionLender objects that you'll use as part of your skill code. This article will cover best practices for logging skill results.


In this Article


Console Logging

Using console.log() is a valid logging method when checking your ShouldIShow and Action functions for tag messages when using the client-side page API.

However, too much console logging and the size of the data you're logging can impact browser and application performance. If using console.log(), limit it to usage in the skill development stages and for users in the Development audience.

var currentScenario;
 currentScenario =;

var currentLoanAPI = api.scenarios[currentScenario].commercialLoanAccounts[model.applicationEventData.contextId]; 

var paymentType = currentLoanAPI.commercialLoanAccount.getPaymentType(); 
       return true;


Error Logging

To log any other component of your skill outside of the ShouldIShow and Action functions, you will need to log an error to the skill error log, which will make the error available in the skill history. This can be done using the throw error method.

Example Use Cases

  • Because the skill you're running has to meet a condition (or multiple) to run, if a condition fails, then throwing an error for a condition can help you pinpoint which condition failed that caused the skill fail.
    //get the opportunity stage
    let oppId = applicationEvent.applicationEventData && applicationEvent.applicationEventData.opportunityId;
    return skillContext.powers.precisionLender.opportunity.api.v2.getOpportunityResponse(oppId)
        .then(async(opportunityResponse: OpportunityResponse) => {
        if(!opportunityResponse) {throw new Error("Unable to access opportunityResponse from the PrecisionLender API")};
  • If you're unsure of the shape of an object, you can throw an error to return that shape. In this case, you need to make sure you stringify the object.
    throw new Error(JSON.stringify(objectToSee, null, 2))
    //For Example
    let loanAccounts = opportunityModel.engineModel.commercialLoanAccounts.length > 0
    if (loanAccounts) {throw new Error(JSON.stringify(loanAccounts,null,2))}
  • For more advanced skill writers, if using async-await, you can put a try-catch around the entire run file to do more custom error handling, and as part of that, throw the error so that it logs to the history. If you use a try-catch and do not throw an error, Andi will will recognize a failed skill run as successful. An alternative to putting it around the entire run file would be to catch and handle promise errors.
    //around the run file
    try {
        // do normal run file processing
    } catch (err) {
        // do custom error handling
        throw err;
    //promise errors
    return skillContext.powers.precisionLender.opportunity.api.v2.getOpportunityResponse(oppId)
        .then((opportunityResponse: OpportunityResponse) => {
            return anotherPromiseThatDoesThings
        .catch(err => throw err);
Was this article helpful?
0 out of 0 found this helpful