refactor: escalate errors from parser

This commit is contained in:
Carlos Valente
2024-06-23 22:47:24 +02:00
committed by Carlos Valente
parent de9af5aaa2
commit 20d9df2501
7 changed files with 440 additions and 184 deletions
@@ -16,7 +16,7 @@ import { ensureDirectory } from '../../utils/fileManagement.js';
import { cellRequestFromEvent, type ClientSecret, getA1Notation, validateClientSecret } from './sheetUtils.js';
import { parseExcel } from '../../utils/parser.js';
import { logger } from '../../classes/Logger.js';
import { parseCustomFields, parseRundown } from '../../utils/parserFunctions.js';
import { parseRundown } from '../../utils/parserFunctions.js';
import { getRundown } from '../rundown-service/rundownUtils.js';
const sheetScope = 'https://www.googleapis.com/auth/spreadsheets';
@@ -366,10 +366,9 @@ export async function download(
}
const dataFromSheet = parseExcel(googleResponse.data.values, options);
const rundown = parseRundown(dataFromSheet);
const { customFields, rundown } = parseRundown(dataFromSheet);
if (rundown.length < 1) {
throw new Error('Sheet: Could not find data to import in the worksheet');
}
const customFields = parseCustomFields(dataFromSheet);
return { rundown, customFields };
}