def output_script_error(error, cfg):
    """
    Cleanly outputs an error return from an Apps Script API call
    """
    cfg['logger'].error('Script error', error_message=str(error['errorMessage']))
    if 'scriptStackTraceElements' in error:
        cfg['logger'].error('Script error stracktrace follows')
        for trace in error['scriptStackTraceElements']:
            cfg['logger'].error('\t%s: %s' % (str(trace['function']),
                                              str(trace['lineNumber'])))
    return 'Error'