code: function failLambdaCallback(callback, error, event, context) {
    return Promises.try(() => {
      // Convert the error into an "API" error with an HTTP status code
      const apiError = appErrors.toAppError(error);
  
      // Resolve the AWS request id (if available)
      apiError.awsRequestId = trim(apiError.awsRequestId) || trim(error.awsRequestId) ||
        (context && (trim(context.awsRequestId) || (context.awsContext && trim(context.awsContext.awsRequestId)))) ||
        undefined;
  
      // Resolve the audit reference (if available)
      apiError.auditRef = trim(apiError.auditRef) || trim(error.auditRef) || undefined;
  
      const errorResponse = toCustomOrDefaultErrorResponse(apiError, event, context);
      return executePreFailureCallback(apiError, errorResponse, event, context)
        .then(() => callback(stringify(errorResponse), null))
        .catch(err => {
          console.error(`Unexpected failure after executePreFailureCallback`, err);
          return callback(stringify(errorResponse), null);
        });
    }).catch(err => {
      console.error(`Unexpected failure during failLambdaCallback`, err);
      return callback(stringify(error), null);
    });
  }
docs: Fails the given callback of an AWS Lambda, which is NOT exposed via API Gateway, with the given error, by first
  attempting to convert the given error into one of the standard app errors (see {@linkcode core-functions/app-errors})
  and then invoking the given callback with a JSON stringified version of the converted app error.
  
  @see module:core-functions/app-errors#toAppError
  
  @param {Function} callback - the callback function passed as the last argument to your Lambda function on invocation
  @param {Error} error - the error with which you need to fail your Lambda
  @param {string|undefined} [error.auditRef] - an optional audit reference
  @param {string|undefined} [error.awsRequestId] - an optional AWS request ID
  @param {AWSEvent} event - the AWS event passed to your handler
  @param {StandardHandlerContext} context - the context being used